aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2012-01-15 18:35:33 +0200
committerFilippos Karapetis2012-01-15 18:35:33 +0200
commit0f39a4367535fcd4bfa4c41340d90d7856d086d8 (patch)
tree98169d393dd25b9fbe2a79a7eeca6868f5b78c6c /engines/sci
parent780b2eff1636985b900db6d0908cc6d3d395f409 (diff)
downloadscummvm-rg350-0f39a4367535fcd4bfa4c41340d90d7856d086d8.tar.gz
scummvm-rg350-0f39a4367535fcd4bfa4c41340d90d7856d086d8.tar.bz2
scummvm-rg350-0f39a4367535fcd4bfa4c41340d90d7856d086d8.zip
SCI: Plug loads of memory leaks in the SCI32 graphics code
Many thanks to digitall for finding these
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/frameout.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index e3fac80f7c..b12413ab69 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -61,12 +61,13 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd
}
GfxFrameout::~GfxFrameout() {
+ clear();
}
void GfxFrameout::clear() {
- _screenItems.clear();
+ deletePlaneItems(NULL_REG);
_planes.clear();
- _planePictures.clear();
+ deletePlanePictures(NULL_REG);
}
void GfxFrameout::kernelAddPlane(reg_t object) {
@@ -214,12 +215,15 @@ void GfxFrameout::addPlanePicture(reg_t object, GuiResourceId pictureId, uint16
}
void GfxFrameout::deletePlanePictures(reg_t object) {
- for (PlanePictureList::iterator it = _planePictures.begin(); it != _planePictures.end(); it++) {
- if (it->object == object) {
+ PlanePictureList::iterator it = _planePictures.begin();
+
+ while (it != _planePictures.end()) {
+ if (it->object == object || object.isNull()) {
+ delete it->pictureCels;
delete it->picture;
- _planePictures.erase(it);
- deletePlanePictures(object);
- return;
+ it = _planePictures.erase(it);
+ } else {
+ ++it;
}
}
}
@@ -272,17 +276,28 @@ void GfxFrameout::kernelDeleteScreenItem(reg_t object) {
}
_screenItems.remove(itemEntry);
+ delete itemEntry;
}
void GfxFrameout::deletePlaneItems(reg_t planeObject) {
FrameoutList::iterator listIterator = _screenItems.begin();
while (listIterator != _screenItems.end()) {
- reg_t itemPlane = readSelector(_segMan, (*listIterator)->object, SELECTOR(plane));
- if (planeObject == itemPlane)
+ bool objectMatches = false;
+ if (!planeObject.isNull()) {
+ reg_t itemPlane = readSelector(_segMan, (*listIterator)->object, SELECTOR(plane));
+ objectMatches = (planeObject == itemPlane);
+ } else {
+ objectMatches = true;
+ }
+
+ if (objectMatches) {
+ FrameoutEntry *itemEntry = *listIterator;
listIterator = _screenItems.erase(listIterator);
- else
+ delete itemEntry;
+ } else {
++listIterator;
+ }
}
}