HUGO: Fix crash when hugo.dat is not the expected version

svn-id: r54124
This commit is contained in:
Arnaud Boutonné 2010-11-07 18:52:47 +00:00
parent 279a760c5a
commit 86d005e4a3
3 changed files with 37 additions and 23 deletions

View File

@ -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();

View File

@ -46,7 +46,7 @@
namespace Hugo {
ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm) {
ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0) {
}
ObjectHandler::~ObjectHandler() {

View File

@ -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);
}
}
/**