aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2012-01-15 20:11:30 +0200
committerFilippos Karapetis2012-01-15 20:11:30 +0200
commit34b297748c8e67995d84453b2b36b388161b93dc (patch)
treed52742a2bf67fad489677a291f6a93de41aaa2d5 /engines/sci/engine
parent56fb56936e36b3a91ab575a78514383199388ed9 (diff)
downloadscummvm-rg350-34b297748c8e67995d84453b2b36b388161b93dc.tar.gz
scummvm-rg350-34b297748c8e67995d84453b2b36b388161b93dc.tar.bz2
scummvm-rg350-34b297748c8e67995d84453b2b36b388161b93dc.zip
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
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kstring.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 5ae18c1367..0f79c3592c 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);