aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDavid Turner2010-12-05 22:02:04 +0000
committerDavid Turner2010-12-05 22:02:04 +0000
commitd3719a81927a666e5065cc56c9e882f2cc351e69 (patch)
tree0f8d76d1dc8c1bb82b6a097b2e5148663a26a835 /engines
parent06310f81761bee8db9d63da969dead2af7c537d7 (diff)
downloadscummvm-rg350-d3719a81927a666e5065cc56c9e882f2cc351e69.tar.gz
scummvm-rg350-d3719a81927a666e5065cc56c9e882f2cc351e69.tar.bz2
scummvm-rg350-d3719a81927a666e5065cc56c9e882f2cc351e69.zip
HUGO: Partial Fix For Leaks from ReadPCX()
The shutdown() call has been reinstated, and freeObjects() now works without a double free and thus segfault, but this still misses some allocated resources... svn-id: r54789
Diffstat (limited to 'engines')
-rw-r--r--engines/hugo/hugo.cpp4
-rw-r--r--engines/hugo/object.cpp20
2 files changed, 18 insertions, 6 deletions
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index f1f762db2f..629e7e6e7d 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -86,9 +86,7 @@ HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(sy
}
HugoEngine::~HugoEngine() {
- // FIXME - Need to call this to remove memory leaks,
- // but this currently causes double free issues.
- //shutdown();
+ shutdown();
freeTexts(_textData);
freeTexts(_stringtData);
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index b8e1b34de5..90ab88d82b 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -217,17 +217,31 @@ void ObjectHandler::freeObjects() {
// Free all sequence lists and image data
for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i];
+ debugC(1, kDebugObject, "\tObject %d: %d Sequences", i, obj->seqNumb);
+
+ debugC(1, kDebugObject, "\tObject %d->currImagePtr: %p", i, (void *) obj->currImagePtr);
+ // FIXME - currImagePtr can be an alias into one of obj->seqList[].seqPtr so need to avoid freeing in that case.
+ //if (obj->currImagePtr != 0 && obj->currImagePtr != seq) {
+ // free(obj->currImagePtr);
+ // obj->currImagePtr = 0;
+ //}
+
for (int j = 0; j < obj->seqNumb; j++) { // for each sequence
+ debugC(1, kDebugObject, "\tSequence %d: seqlist %p", j, (void *) &obj->seqList[j]);
+ debugC(1, kDebugObject, "\tSequence %d: seqPtr %p", j, (void *) obj->seqList[j].seqPtr);
seq_t *seq = obj->seqList[j].seqPtr; // Free image
- if (obj->currImagePtr!= 0)
- free(obj->currImagePtr);
if (seq == 0) // Failure during database load
break;
do {
- free(seq->imagePtr);
+ debugC(1, kDebugObject, "\t\tseq->ImagePtr: %p", seq->imagePtr);
+ if (seq->imagePtr != 0) {
+ free(seq->imagePtr);
+ seq->imagePtr = 0;
+ }
seq = seq->nextSeqPtr;
} while (seq != obj->seqList[j].seqPtr);
free(seq); // Free sequence record
+ seq = 0;
}
}
}