diff options
author | Johannes Schickel | 2010-01-23 18:24:11 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-23 18:24:11 +0000 |
commit | edbc3683987faf7487b10513a812ca2857a04771 (patch) | |
tree | f7505586925112dfce04542096b22da5fdcbde31 /engines/sci/engine | |
parent | 2489340cc888d69a2b3b81b3ee27845392c0493f (diff) | |
download | scummvm-rg350-edbc3683987faf7487b10513a812ca2857a04771.tar.gz scummvm-rg350-edbc3683987faf7487b10513a812ca2857a04771.tar.bz2 scummvm-rg350-edbc3683987faf7487b10513a812ca2857a04771.zip |
Cleanup. (And along with it add some additional asserts).
svn-id: r47482
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index b12ef0a0a4..bf188e1d43 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -682,18 +682,22 @@ static void reconstruct_stack(EngineState *retval) { } static void load_script(EngineState *s, Script *scr) { - Resource *script, *heap = NULL; - scr->_buf = (byte *)malloc(scr->_bufSize); assert(scr->_buf); - script = s->resMan->findResource(ResourceId(kResourceTypeScript, scr->_nr), 0); - if (getSciVersion() >= SCI_VERSION_1_1) - heap = s->resMan->findResource(ResourceId(kResourceTypeHeap, scr->_nr), 0); + Resource *script = s->resMan->findResource(ResourceId(kResourceTypeScript, scr->_nr), 0); + assert(script != 0); + assert(scr->_bufSize <= script->size); memcpy(scr->_buf, script->data, script->size); + if (getSciVersion() >= SCI_VERSION_1_1) { + Resource *heap = s->resMan->findResource(ResourceId(kResourceTypeHeap, scr->_nr), 0); + assert(heap != 0); + scr->_heapStart = scr->_buf + scr->_scriptSize; + + assert(scr->_bufSize - scr->_scriptSize <= heap->size); memcpy(scr->_heapStart, heap->data, heap->size); } } |