[Scummvm-git-logs] scummvm master -> 377cf606dd6c0e071907c263ffecd37a63ba96e7
peterkohaut
peterkohaut at users.noreply.github.com
Thu Jul 18 01:03:03 CEST 2019
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:
377cf606dd COMMON: Fix U32String initialization issues
Commit: 377cf606dd6c0e071907c263ffecd37a63ba96e7
https://github.com/scummvm/scummvm/commit/377cf606dd6c0e071907c263ffecd37a63ba96e7
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2019-07-18T01:00:01+02:00
Commit Message:
COMMON: Fix U32String initialization issues
Bug 1:
If the original C string contained chars > 127 they would be stored
as huge u32 numbers due to the underflow as char is signed.
It still might end-up with invalid UTF32 characters, but now the caller
can control it.
Bug 2:
The inline storage was not properly initialized when U32String was
initalized from shorter non-UTF32 strings.
Changed paths:
common/ustr.cpp
diff --git a/common/ustr.cpp b/common/ustr.cpp
index c0a2412..520016d 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -90,7 +90,7 @@ U32String::U32String(const char *beginP, const char *endP) : _size(0), _str(_sto
initWithCStr(beginP, endP - beginP);
}
-U32String::U32String(const String &str) : _size(0) {
+U32String::U32String(const String &str) : _size(0), _str(_storage) {
initWithCStr(str.c_str(), str.size());
}
@@ -423,7 +423,7 @@ void U32String::initWithCStr(const char *str, uint32 len) {
// Copy the string into the storage area
for (size_t idx = 0; idx < len; ++idx, ++str)
- _str[idx] = *str;
+ _str[idx] = (byte)(*str);
_str[len] = 0;
}
More information about the Scummvm-git-logs
mailing list