From 4d3707d7956352acb69f05e45084ee1964a2577f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 7 Jan 2016 00:51:14 +0100 Subject: WAGE: Plugged even more memory leaks --- engines/wage/design.cpp | 3 ++- engines/wage/entities.cpp | 3 +++ engines/wage/entities.h | 1 + engines/wage/world.cpp | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index 95151373e7..5ce1ff376c 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -75,7 +75,8 @@ Design::Design(Common::SeekableReadStream *data) { Design::~Design() { free(_data); - _surface->free(); + if (_surface && _surface->getPixels()) + _surface->free(); delete _surface; } diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index 61f579e4d2..1a9e936a61 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -234,6 +234,9 @@ Obj::Obj(String name, Common::SeekableReadStream *data) { delete data; } +Obj::~Obj() { +} + Chr *Obj::removeFromChr() { if (_currentOwner != NULL) { for (int i = (int)_currentOwner->_inventory.size() - 1; i >= 0; i--) diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 7cfe35ff63..ba190860ad 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -315,6 +315,7 @@ class Obj : public Weapon, public Designed { public: Obj() : _currentOwner(NULL), _currentScene(NULL) {} Obj(String name, Common::SeekableReadStream *data); + ~Obj(); enum ObjectType { REGULAR_WEAPON = 1, diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index 7a15b9314a..c525bd33cc 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -363,9 +363,12 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res Common::String message = readPascalString(res); if (i == itemIndex) { Common::String *msg = new Common::String(message); + delete res; return msg; } } + + delete res; } return NULL; -- cgit v1.2.3