[Scummvm-git-logs] scummvm master -> 1b67a0f0691802464a4e3a803a8d95a10b18bea8
criezy
criezy at scummvm.org
Mon Aug 31 23:12:20 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1b67a0f069 COMMON: Fix assingning a String to a U32String
Commit: 1b67a0f0691802464a4e3a803a8d95a10b18bea8
https://github.com/scummvm/scummvm/commit/1b67a0f0691802464a4e3a803a8d95a10b18bea8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-09-01T00:12:03+01:00
Commit Message:
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).
Changed paths:
common/ustr.cpp
diff --git a/common/ustr.cpp b/common/ustr.cpp
index 843672d58a..4427239d5d 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -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;
}
More information about the Scummvm-git-logs
mailing list