diff options
| author | Torbjörn Andersson | 2006-06-04 09:14:07 +0000 |
|---|---|---|
| committer | Torbjörn Andersson | 2006-06-04 09:14:07 +0000 |
| commit | 2e071b59d6b6295bc0949f4e19f92586828d5b4a (patch) | |
| tree | 88c9dcb418630b37b1824affb4f4418b72520e5e | |
| parent | 8792ab873bad1924007f0bc5153d75909be83121 (diff) | |
| download | scummvm-rg350-2e071b59d6b6295bc0949f4e19f92586828d5b4a.tar.gz scummvm-rg350-2e071b59d6b6295bc0949f4e19f92586828d5b4a.tar.bz2 scummvm-rg350-2e071b59d6b6295bc0949f4e19f92586828d5b4a.zip | |
When ensureCapacity() does not have an old string to copy, make sure the newly
allocated one is terminated. Hopefully this will keep the SCUMM save dialog
from randomly adding garbage to my savegame names.
svn-id: r22908
| -rw-r--r-- | common/str.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/str.cpp b/common/str.cpp index c5616baf52..0940d50bdc 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -265,10 +265,12 @@ void String::ensureCapacity(int new_len, bool keep_old) { char *newStr = (char *)malloc(newCapacity+1); - if (keep_old && _str) + if (keep_old && _str) { memcpy(newStr, _str, _len + 1); - else + } else { _len = 0; + newStr[0] = 0; + } decRefCount(); _refCount = 0; |
