diff options
author | Filippos Karapetis | 2010-11-17 21:47:05 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-11-17 21:47:05 +0000 |
commit | bd844a8c92e4176f613d358425cc3eeb0ead2bda (patch) | |
tree | ec83da247817ba18f0185e763bbe0ceaab1ee05c | |
parent | ddbda3eb152d94127369975cf4b436c3dfd072df (diff) | |
download | scummvm-rg350-bd844a8c92e4176f613d358425cc3eeb0ead2bda.tar.gz scummvm-rg350-bd844a8c92e4176f613d358425cc3eeb0ead2bda.tar.bz2 scummvm-rg350-bd844a8c92e4176f613d358425cc3eeb0ead2bda.zip |
SCI: Call lookupArray() after allocateArray() when duplicating arrays
This ensures that the pointer to the element that lookupArray() returned
won't be invalidated in case the array is reallocated because of
allocateArray() - same issue as in kClone()
svn-id: r54306
-rw-r--r-- | engines/sci/engine/klists.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 2188087b8c..ca23469e44 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -702,9 +702,12 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) { // Not implemented in SSCI return s->r_acc; case 8: { // Dup - SciArray<reg_t> *array = s->_segMan->lookupArray(argv[1]); reg_t arrayHandle; SciArray<reg_t> *dupArray = s->_segMan->allocateArray(&arrayHandle); + // This must occur after allocateArray, as inserting a new object + // in the heap object list might invalidate this pointer. Also refer + // to the same issue in kClone() + SciArray<reg_t> *array = s->_segMan->lookupArray(argv[1]); dupArray->setType(array->getType()); dupArray->setSize(array->getSize()); |