diff options
author | Filippos Karapetis | 2011-07-07 03:42:08 +0300 |
---|---|---|
committer | Filippos Karapetis | 2011-07-07 03:43:06 +0300 |
commit | 72da8ef5adf82d8a65da299207f30af5058ca8a9 (patch) | |
tree | 1965e978ad2cf19944379a826f2c36d7262ba323 /engines/sci/engine/kstring.cpp | |
parent | 8e75d9c84b62c86a3484f69544962bd2e4e9cd77 (diff) | |
download | scummvm-rg350-72da8ef5adf82d8a65da299207f30af5058ca8a9.tar.gz scummvm-rg350-72da8ef5adf82d8a65da299207f30af5058ca8a9.tar.bz2 scummvm-rg350-72da8ef5adf82d8a65da299207f30af5058ca8a9.zip |
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.
Diffstat (limited to 'engines/sci/engine/kstring.cpp')
-rw-r--r-- | engines/sci/engine/kstring.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 9f10691767..7b8db22e3f 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++) |