mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 04:33:09 +00:00
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.
This commit is contained in:
parent
8e75d9c84b
commit
72da8ef5ad
@ -730,6 +730,10 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
|
|||||||
case 8: { // Dup
|
case 8: { // Dup
|
||||||
const char *rawString = 0;
|
const char *rawString = 0;
|
||||||
uint32 size = 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()) {
|
if (argv[1].segment == s->_segMan->getStringSegmentId()) {
|
||||||
SciString *string = s->_segMan->lookupString(argv[1]);
|
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;
|
size = string.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_t stringHandle;
|
|
||||||
SciString *dupString = s->_segMan->allocateString(&stringHandle);
|
|
||||||
dupString->setSize(size);
|
dupString->setSize(size);
|
||||||
|
|
||||||
for (uint32 i = 0; i < size; i++)
|
for (uint32 i = 0; i < size; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user