aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Špalek2009-10-16 00:09:20 +0000
committerRobert Špalek2009-10-16 00:09:20 +0000
commitb2bf21f0da168d1a88f3b52b03825699074dc91c (patch)
tree0091a48b0c5a1be497617f83b2994823e76bc515
parent1dfc808aadd82347020882d472b2c27a6dddff60 (diff)
downloadscummvm-rg350-b2bf21f0da168d1a88f3b52b03825699074dc91c.tar.gz
scummvm-rg350-b2bf21f0da168d1a88f3b52b03825699074dc91c.tar.bz2
scummvm-rg350-b2bf21f0da168d1a88f3b52b03825699074dc91c.zip
Fix memory leaks when reading thumbnails
svn-id: r45142
-rw-r--r--engines/draci/detection.cpp8
-rw-r--r--engines/draci/saveload.cpp10
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();