aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDavid Turner2010-12-06 01:56:42 +0000
committerDavid Turner2010-12-06 01:56:42 +0000
commitdda67d651b2e5a8ed2a76c431d992d65c8f06c92 (patch)
treec2c68b2a834236a80056a02f146c81a5b014e6a0 /engines
parent5ee7a44cf65ed0519f3859bfe9e77643acc67004 (diff)
downloadscummvm-rg350-dda67d651b2e5a8ed2a76c431d992d65c8f06c92.tar.gz
scummvm-rg350-dda67d651b2e5a8ed2a76c431d992d65c8f06c92.tar.bz2
scummvm-rg350-dda67d651b2e5a8ed2a76c431d992d65c8f06c92.zip
HUGO: Fixed ReadPCX Memory Leak
freeObjects now works correctly. svn-id: r54796
Diffstat (limited to 'engines')
-rw-r--r--engines/hugo/object.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 90ab88d82b..6597e89cef 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -217,31 +217,26 @@ 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 (seq == 0) // Failure during database load
+ for (int j = 0; j < obj->seqNumb; j++) {
+ seq_t *seq = obj->seqList[j].seqPtr;
+ seq_t *next;
+ if (seq == 0) // Failure during database load
break;
- do {
- 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) {
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;
+ next = seq->nextSeqPtr;
+ free(seq);
+ seq = next;
+ }
+ free(seq);
}
}
}