[Scummvm-git-logs] scummvm branch-2-2 -> 04d2d91aba8ce03ade93a4e955627fd902ee78aa

criezy criezy at scummvm.org
Mon Aug 31 23:23:34 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:
04d2d91aba COMMON: Fix assingning a String to a U32String


Commit: 04d2d91aba8ce03ade93a4e955627fd902ee78aa
    https://github.com/scummvm/scummvm/commit/04d2d91aba8ce03ade93a4e955627fd902ee78aa
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-09-01T00:14:58+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 5a45a8bec1..1e2644deb5 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -126,6 +126,7 @@ U32String &U32String::operator=(const U32String &str) {
 }
 
 U32String &U32String::operator=(const String &str) {
+	clear();
 	initWithCStr(str.c_str(), str.size());
 	return *this;
 }
@@ -135,6 +136,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