aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/hugo.cpp48
-rw-r--r--engines/hugo/object.cpp2
-rw-r--r--engines/hugo/schedule.cpp10
3 files changed, 37 insertions, 23 deletions
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 774abc0343..fab2e2d17d 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -86,13 +86,17 @@ HugoEngine::~HugoEngine() {
free(_textData);
free(_stringtData);
- for (int i = 0; _arrayNouns[i]; i++)
- free(_arrayNouns[i]);
- free(_arrayNouns);
+ if (_arrayNouns) {
+ for (int i = 0; _arrayNouns[i]; i++)
+ free(_arrayNouns[i]);
+ free(_arrayNouns);
+ }
- for (int i = 0; _arrayVerbs[i]; i++)
- free(_arrayVerbs[i]);
- free(_arrayVerbs);
+ if (_arrayVerbs) {
+ for (int i = 0; _arrayVerbs[i]; i++)
+ free(_arrayVerbs[i]);
+ free(_arrayVerbs);
+ }
free(_screenNames);
_screen->freePalette();
@@ -108,25 +112,33 @@ HugoEngine::~HugoEngine() {
free(_hotspots);
free(_invent);
- for (int i = 0; i < _usesSize; i++)
- free(_uses[i].targets);
- free(_uses);
+ if (_uses) {
+ for (int i = 0; i < _usesSize; i++)
+ free(_uses[i].targets);
+ free(_uses);
+ }
free(_catchallList);
- for (int i = 0; i < _backgroundObjectsSize; i++)
- free(_backgroundObjects[i]);
- free(_backgroundObjects);
+ if (_backgroundObjects) {
+ for (int i = 0; i < _backgroundObjectsSize; i++)
+ free(_backgroundObjects[i]);
+ free(_backgroundObjects);
+ }
free(_points);
- for (int i = 0; i < _cmdListSize; i++)
- free(_cmdList[i]);
- free(_cmdList);
+ if (_cmdList) {
+ for (int i = 0; i < _cmdListSize; i++)
+ free(_cmdList[i]);
+ free(_cmdList);
+ }
- for (int i = 0; i < _screenActsSize; i++)
- free(_screenActs[i]);
- free(_screenActs);
+ if (_cmdList) {
+ for (int i = 0; i < _screenActsSize; i++)
+ free(_screenActs[i]);
+ free(_screenActs);
+ }
_object->freeObjectArr();
_scheduler->freeActListArr();
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index e54bf2f342..6aec9d1378 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -46,7 +46,7 @@
namespace Hugo {
-ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm) {
+ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0) {
}
ObjectHandler::~ObjectHandler() {
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index ad48513c90..6f88ce98bf 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -42,7 +42,7 @@
namespace Hugo {
-Scheduler::Scheduler(HugoEngine *vm) : _vm(vm) {
+Scheduler::Scheduler(HugoEngine *vm) : _vm(vm), _actListArr(0) {
}
Scheduler::~Scheduler() {
@@ -829,9 +829,11 @@ void Scheduler::loadActListArr(Common::File &in) {
void Scheduler::freeActListArr() {
debugC(6, kDebugSchedule, "freeActListArr()");
- for (int i = 0; i < _actListArrSize; i++)
- free(_actListArr[i]);
- free(_actListArr);
+ if (_actListArr) {
+ for (int i = 0; i < _actListArrSize; i++)
+ free(_actListArr[i]);
+ free(_actListArr);
+ }
}
/**