aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
authorArnaud Boutonné2010-11-07 18:52:47 +0000
committerArnaud Boutonné2010-11-07 18:52:47 +0000
commit86d005e4a34124e26cea3e1f9d55dd8a8df5be89 (patch)
tree825878ce5904ccf14179ccf652f1b834db951e23 /engines/hugo
parent279a760c5a833b51de3217f8eadda7cf57596532 (diff)
downloadscummvm-rg350-86d005e4a34124e26cea3e1f9d55dd8a8df5be89.tar.gz
scummvm-rg350-86d005e4a34124e26cea3e1f9d55dd8a8df5be89.tar.bz2
scummvm-rg350-86d005e4a34124e26cea3e1f9d55dd8a8df5be89.zip
HUGO: Fix crash when hugo.dat is not the expected version
svn-id: r54124
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);
+ }
}
/**