diff options
author | Sven Hesse | 2010-01-31 13:18:32 +0000 |
---|---|---|
committer | Sven Hesse | 2010-01-31 13:18:32 +0000 |
commit | 6248362c38b97c40f0a71544381397657a2b041f (patch) | |
tree | 28270813cdb42f10a0e77605c005d11e184661ce /engines | |
parent | 2185f6b1644eb8420afd4b9579828d5cc4838dc4 (diff) | |
download | scummvm-rg350-6248362c38b97c40f0a71544381397657a2b041f.tar.gz scummvm-rg350-6248362c38b97c40f0a71544381397657a2b041f.tar.bz2 scummvm-rg350-6248362c38b97c40f0a71544381397657a2b041f.zip |
Properly deleting the TOT resource table again when loading failed
svn-id: r47750
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/resources.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/engines/gob/resources.cpp b/engines/gob/resources.cpp index ddc717658e..9e2817e4bc 100644 --- a/engines/gob/resources.cpp +++ b/engines/gob/resources.cpp @@ -159,6 +159,16 @@ bool Resources::load(const Common::String &fileName) { bool hasTOTRes = loadTOTResourceTable(); bool hasEXTRes = loadEXTResourceTable(); + if (!hasTOTRes) { + delete _totResourceTable; + _totResourceTable = 0; + } + + if (!hasEXTRes) { + delete _extResourceTable; + _extResourceTable = 0; + } + if (!hasTOTRes && !hasEXTRes) return false; @@ -610,9 +620,10 @@ bool Resources::dumpResource(const Resource &resource, uint16 id, } Resource *Resources::getTOTResource(uint16 id) const { - if (id >= _totResourceTable->itemsCount) { + if (!_totResourceTable || (id >= _totResourceTable->itemsCount)) { warning("Trying to load non-existent TOT resource (%s, %d/%d)", - _totFile.c_str(), id, _totResourceTable->itemsCount - 1); + _totFile.c_str(), id, + _totResourceTable ? (_totResourceTable->itemsCount - 1) : -1); return 0; } @@ -643,7 +654,7 @@ Resource *Resources::getEXTResource(uint16 id) const { return 0; } - assert(_totResourceTable->items); + assert(_extResourceTable->items); EXTResourceItem &extItem = _extResourceTable->items[id]; |