COMMON: Fix assingning a String to a U32String

When assigning a String or char * to an existing U32String, the code
assumed that the current _str pointed to the internal storage. But
that is not the case if the U32String contains a string longer
than the internal storage capacity prior to the assignment, and
this led to various memory issues (and usually a crash down the
line).
This commit is contained in:
Thierry Crozat 2020-08-31 23:59:47 +01:00
parent 7f738abe4f
commit 1b67a0f069

View File

@ -127,6 +127,7 @@ U32String &U32String::operator=(const U32String &str) {
}
U32String &U32String::operator=(const String &str) {
clear();
initWithCStr(str.c_str(), str.size());
return *this;
}
@ -136,6 +137,7 @@ U32String &U32String::operator=(const value_type *str) {
}
U32String &U32String::operator=(const char *str) {
clear();
initWithCStr(str, strlen(str));
return *this;
}