[Scummvm-cvs-logs] SF.net SVN: scummvm: [22908] scummvm/trunk/common/str.cpp

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun Jun 4 11:14:11 CEST 2006


Revision: 22908
Author:   eriktorbjorn
Date:     2006-06-04 02:14:07 -0700 (Sun, 04 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22908&view=rev

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/common/str.cpp
Modified: scummvm/trunk/common/str.cpp
===================================================================
--- scummvm/trunk/common/str.cpp	2006-06-04 00:03:30 UTC (rev 22907)
+++ scummvm/trunk/common/str.cpp	2006-06-04 09:14:07 UTC (rev 22908)
@@ -265,10 +265,12 @@
 
 	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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list