mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
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
This commit is contained in:
parent
56fb56936e
commit
34b297748c
@ -748,18 +748,21 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
|
|||||||
const char *rawString = 0;
|
const char *rawString = 0;
|
||||||
uint32 size = 0;
|
uint32 size = 0;
|
||||||
reg_t stringHandle;
|
reg_t stringHandle;
|
||||||
|
SciString *sciString;
|
||||||
|
Common::String commonString;
|
||||||
|
|
||||||
// We allocate the new string first because if the StringTable needs to
|
// We allocate the new string first because if the StringTable needs to
|
||||||
// grow, our rawString pointer will be invalidated
|
// grow, our rawString pointer will be invalidated
|
||||||
SciString *dupString = s->_segMan->allocateString(&stringHandle);
|
SciString *dupString = s->_segMan->allocateString(&stringHandle);
|
||||||
|
|
||||||
if (argv[1].segment == s->_segMan->getStringSegmentId()) {
|
if (argv[1].segment == s->_segMan->getStringSegmentId()) {
|
||||||
SciString *string = s->_segMan->lookupString(argv[1]);
|
sciString = s->_segMan->lookupString(argv[1]);
|
||||||
rawString = string->getRawData();
|
rawString = sciString->getRawData();
|
||||||
size = string->getSize();
|
size = sciString->getSize();
|
||||||
} else {
|
} else {
|
||||||
Common::String string = s->_segMan->getString(argv[1]);
|
commonString = s->_segMan->getString(argv[1]);
|
||||||
rawString = string.c_str();
|
rawString = commonString.c_str();
|
||||||
size = string.size() + 1;
|
size = commonString.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dupString->setSize(size);
|
dupString->setSize(size);
|
||||||
|
Loading…
Reference in New Issue
Block a user