[Scummvm-cvs-logs] scummvm master -> 34b297748c8e67995d84453b2b36b388161b93dc

bluegr md5 at scummvm.org
Sun Jan 15 19:12:22 CET 2012


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:
34b297748c SCI: Fix a nasty bug in kString(Dup)


Commit: 34b297748c8e67995d84453b2b36b388161b93dc
    https://github.com/scummvm/scummvm/commit/34b297748c8e67995d84453b2b36b388161b93dc
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-01-15T10:11:30-08:00

Commit Message:
SCI: Fix a nasty bug in kString(Dup)

The rawString variable is no longer pointing to invalidated data. This
fixes cases where strings are manipulated by game scripts, such as the
graveyard and rada drum puzzles in GK1

Changed paths:
    engines/sci/engine/kstring.cpp



diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 5ae18c1..0f79c35 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -748,18 +748,21 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
 		const char *rawString = 0;
 		uint32 size = 0;
 		reg_t stringHandle;
+		SciString *sciString;
+		Common::String commonString;
+
 		// We allocate the new string first because if the StringTable needs to
 		// grow, our rawString pointer will be invalidated
 		SciString *dupString = s->_segMan->allocateString(&stringHandle);
 
 		if (argv[1].segment == s->_segMan->getStringSegmentId()) {
-			SciString *string = s->_segMan->lookupString(argv[1]);
-			rawString = string->getRawData();
-			size = string->getSize();
+			sciString = s->_segMan->lookupString(argv[1]);
+			rawString = sciString->getRawData();
+			size = sciString->getSize();
 		} else {
-			Common::String string = s->_segMan->getString(argv[1]);
-			rawString = string.c_str();
-			size = string.size() + 1;
+			commonString = s->_segMan->getString(argv[1]);
+			rawString = commonString.c_str();
+			size = commonString.size() + 1;
 		}
 
 		dupString->setSize(size);






More information about the Scummvm-git-logs mailing list