diff options
Diffstat (limited to 'common/str.cpp')
-rw-r--r-- | common/str.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp index f7cb84aa05..1b857546a8 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -288,12 +288,14 @@ void String::insertChar(char c, uint32 p) { } void String::toLowercase() { + // Ensure that the string is not shared ensureCapacity(_len, true); for (uint32 i = 0; i < _len; ++i) _str[i] = tolower(_str[i]); } void String::toUppercase() { + // Ensure that the string is not shared ensureCapacity(_len, true); for (uint32 i = 0; i < _len; ++i) _str[i] = toupper(_str[i]); @@ -367,6 +369,9 @@ void String::trim() { if (_len == 0) return; + // Ensure that the string is not shared + ensureCapacity(_len, true); + // Trim trailing whitespace while (_len >= 1 && isspace(_str[_len-1])) _len--; |