mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 23:26:44 +00:00
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:
parent
7f738abe4f
commit
1b67a0f069
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user