diff options
-rw-r--r-- | engines/draci/detection.cpp | 8 | ||||
-rw-r--r-- | engines/draci/saveload.cpp | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/engines/draci/detection.cpp b/engines/draci/detection.cpp index f9fb7ffa54..3a7301f41d 100644 --- a/engines/draci/detection.cpp +++ b/engines/draci/detection.cpp @@ -146,10 +146,10 @@ SaveStateList DraciMetaEngine::listSaves(const char *target) const { if (Draci::readSavegameHeader(in, header)) { saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); if (header.thumbnail) { - header.thumbnail->free(); - delete header.thumbnail; - } - } + header.thumbnail->free(); + delete header.thumbnail; + } + } delete in; } } diff --git a/engines/draci/saveload.cpp b/engines/draci/saveload.cpp index cebe04bf73..d4142ea433 100644 --- a/engines/draci/saveload.cpp +++ b/engines/draci/saveload.cpp @@ -62,6 +62,7 @@ bool readSavegameHeader(Common::InSaveFile *in, DraciSavegameHeader &header) { // Get the thumbnail header.thumbnail = new Graphics::Surface(); if (!Graphics::loadThumbnail(*in, *header.thumbnail)) { + header.thumbnail->free(); delete header.thumbnail; header.thumbnail = NULL; return false; @@ -131,8 +132,13 @@ Common::Error loadSavegameData(int saveGameIdx, DraciEngine *vm) { // Skip over the savegame header DraciSavegameHeader header; - readSavegameHeader(f, header); - if (header.thumbnail) delete header.thumbnail; + if (!readSavegameHeader(f, header)) { + return Common::kNoGameDataFoundError; + } + if (header.thumbnail) { + header.thumbnail->free(); + delete header.thumbnail; + } // Pre-processing vm->_game->rememberRoomNumAsPrevious(); |