aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2015-04-09 13:44:39 +0300
committerFilippos Karapetis2015-04-09 13:44:39 +0300
commitec999f1cb74dff8c42c69898bb6cbc3823b169dd (patch)
treed0c3fd1f268f788700cf719785bd5ef6133fe1d4 /engines
parent47afe424c194d5d4fd1797948b53f999473fe922 (diff)
downloadscummvm-rg350-ec999f1cb74dff8c42c69898bb6cbc3823b169dd.tar.gz
scummvm-rg350-ec999f1cb74dff8c42c69898bb6cbc3823b169dd.tar.bz2
scummvm-rg350-ec999f1cb74dff8c42c69898bb6cbc3823b169dd.zip
MADS: Plug some memory leaks
Surfaces should be freed (to free their inner allocated surface buffers) before being deleted
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/game.cpp1
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp4
-rw-r--r--engines/mads/scene_data.cpp2
-rw-r--r--engines/mads/sprites.cpp4
-rw-r--r--engines/mads/user_interface.cpp1
5 files changed, 10 insertions, 2 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 72d7988c05..3d1c194612 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -100,6 +100,7 @@ Game::~Game() {
}
delete _saveFile;
+ _surface->free();
delete _surface;
delete _sectionHandler;
}
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 10715797ed..5b9942db07 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -430,7 +430,7 @@ void CopyProtectionDialog::show() {
draw();
Common::KeyState curKey;
- Common::Rect inputArea(110, 165, 210, 175);
+ const Common::Rect inputArea(110, 165, 210, 175);
MSurface *origInput = new MSurface(inputArea.width(), inputArea.height());
_vm->_screen.frameRect(inputArea, TEXTDIALOG_BLACK);
_vm->_screen.copyTo(origInput, inputArea, Common::Point(0, 0));
@@ -471,6 +471,7 @@ void CopyProtectionDialog::show() {
_vm->_screen.updateScreen();
}
+ origInput->free();
delete origInput;
}
@@ -592,6 +593,7 @@ void PictureDialog::save() {
void PictureDialog::restore() {
if (_savedSurface) {
_savedSurface->copyTo(&_vm->_screen);
+ _savedSurface->free();
delete _savedSurface;
_savedSurface = nullptr;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d0e96be1d7..e594406447 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -451,6 +451,8 @@ void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName,
fab.decompress(compressedTileData, compressedTileDataSize, (byte*)newTile->getPixels(), tileWidth * tileHeight);
tileSet.push_back(TileSetList::value_type(newTile));
+ newTile->free();
+ delete newTile;
delete[] compressedTileData;
}
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index bc36b5575a..f15d6456d3 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -347,8 +347,10 @@ void SpriteSlots::drawSprites(MSurface *s) {
spr->copyTo(s, Common::Point(xp, yp), sprite->getTransparencyIndex());
// Free sprite if it was a flipped one
- if (flipped)
+ if (flipped) {
+ spr->free();
delete spr;
+ }
}
}
}
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 93a555d9c7..1e5a1d80d2 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -164,6 +164,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
MSurface *spr = sprite->flipHorizontal();
userInterface.mergeFrom(spr, spr->getBounds(), slot._position,
sprite->getTransparencyIndex());
+ spr->free();
delete spr;
} else {
userInterface.mergeFrom(sprite, sprite->getBounds(), slot._position,