aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2015-04-26 15:29:02 +0200
committerMartin Kiewitz2015-04-26 15:29:02 +0200
commit5f53b9255eb2799906c324ff0e2ad096092a5dec (patch)
treee6f5d77013aa5530264635160d0ca022634892fe /engines
parent5a7dbc3666b29a4bde5673fe20a85e68d02b6c56 (diff)
downloadscummvm-rg350-5f53b9255eb2799906c324ff0e2ad096092a5dec.tar.gz
scummvm-rg350-5f53b9255eb2799906c324ff0e2ad096092a5dec.tar.bz2
scummvm-rg350-5f53b9255eb2799906c324ff0e2ad096092a5dec.zip
SCI: restore: reset ports before loading memory
otherwise we could free hunk space of the loaded saved game
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/savegame.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index d89170ab22..e0c2833572 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -728,9 +728,7 @@ void GfxPalette::saveLoadWithSerializer(Common::Serializer &s) {
}
void GfxPorts::saveLoadWithSerializer(Common::Serializer &s) {
- if (s.isLoading())
- reset(); // remove all script generated windows
-
+ // reset() is called directly way earlier in gamestate_restore()
if (s.getVersion() >= 27) {
uint windowCount = 0;
uint id = PORTS_FIRSTSCRIPTWINDOWID;
@@ -925,6 +923,13 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
// We don't need the thumbnail here, so just read it and discard it
Graphics::skipThumbnail(*fh);
+ // reset ports as one of the first things we do, because that may free() some hunk memory
+ // and we don't want to do that after we read in the saved game hunk memory
+ if (ser.isLoading()) {
+ if (g_sci->_gfxPorts)
+ g_sci->_gfxPorts->reset();
+ }
+
s->reset(true);
s->saveLoadWithSerializer(ser); // FIXME: Error handling?