From 2e071b59d6b6295bc0949f4e19f92586828d5b4a Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 4 Jun 2006 09:14:07 +0000 Subject: 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 --- common/str.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common') 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; -- cgit v1.2.3