[Scummvm-cvs-logs] scummvm master -> 72da8ef5adf82d8a65da299207f30af5058ca8a9

bluegr md5 at scummvm.org
Thu Jul 7 02:46:12 CEST 2011


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:
72da8ef5ad SCI: Applied patch #3357096 with minor modifications


Commit: 72da8ef5adf82d8a65da299207f30af5058ca8a9
    https://github.com/scummvm/scummvm/commit/72da8ef5adf82d8a65da299207f30af5058ca8a9
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-07-06T17:43:06-07:00

Commit Message:
SCI: Applied patch #3357096 with minor modifications

This prevents a string pointer from getting invalidated under some
circumstances in kString(Dup).
Thanks to lephilousophe for the patch.

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



diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 9f10691..7b8db22 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -730,6 +730,10 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
 	case 8: { // Dup
 		const char *rawString = 0;
 		uint32 size = 0;
+		reg_t stringHandle;
+		// 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]);
@@ -741,8 +745,6 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
 			size = string.size() + 1;
 		}
 
-		reg_t stringHandle;
-		SciString *dupString = s->_segMan->allocateString(&stringHandle);
 		dupString->setSize(size);
 
 		for (uint32 i = 0; i < size; i++)






More information about the Scummvm-git-logs mailing list