aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics/frameout.cpp
diff options
context:
space:
mode:
authorColin Snover2017-09-18 22:13:44 -0500
committerColin Snover2017-09-19 19:54:30 -0500
commitd363234129484733c55f961215bcb1343d84392e (patch)
tree280274f3b4d0f9caa2b9b04c94e14f8110567e18 /engines/sci/graphics/frameout.cpp
parenteba9526fdda389d3f82ccd01a845e6e3aed42799 (diff)
downloadscummvm-rg350-d363234129484733c55f961215bcb1343d84392e.tar.gz
scummvm-rg350-d363234129484733c55f961215bcb1343d84392e.tar.bz2
scummvm-rg350-d363234129484733c55f961215bcb1343d84392e.zip
SCI32: Fix GfxFrameout::addPlane from causing possible leaks
Diffstat (limited to 'engines/sci/graphics/frameout.cpp')
-rw-r--r--engines/sci/graphics/frameout.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 9a7bfc804a..d3e08bf1c1 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -275,7 +275,7 @@ void GfxFrameout::kernelAddPlane(const reg_t object) {
updatePlane(*plane);
} else {
plane = new Plane(object);
- addPlane(*plane);
+ addPlane(plane);
}
}
@@ -351,17 +351,17 @@ int16 GfxFrameout::kernelGetHighPlanePri() {
return _planes.getTopSciPlanePriority();
}
-void GfxFrameout::addPlane(Plane &plane) {
- if (_planes.findByObject(plane._object) == nullptr) {
- plane.clipScreenRect(_screenRect);
- _planes.add(&plane);
- } else {
- plane._deleted = 0;
- if (plane._created == 0) {
- plane._moved = g_sci->_gfxFrameout->getScreenCount();
- }
- _planes.sort();
+void GfxFrameout::addPlane(Plane *plane) {
+ // In SSCI, if a plane with the same object ID already existed, this call
+ // would cancel deletion and update an already-existing plane, but callers
+ // expect the passed plane object to become memory-managed by GfxFrameout,
+ // so doing what SSCI did would end up leaking the Plane objects
+ if (_planes.findByObject(plane->_object) != nullptr) {
+ error("Plane %04x:%04x already exists", PRINT_REG(plane->_object));
}
+
+ plane->clipScreenRect(_screenRect);
+ _planes.add(plane);
}
void GfxFrameout::updatePlane(Plane &plane) {