diff options
author | Strangerke | 2014-10-11 09:17:46 +0200 |
---|---|---|
committer | Strangerke | 2014-10-11 09:19:09 +0200 |
commit | 96d99c480be474eaa47df0976f9cd757acab460d (patch) | |
tree | 043f45cf29d66d875fcc4918e79b9f5b846deef4 /engines/cge | |
parent | db95979a2401711089f747c202f8334b15a2d400 (diff) | |
download | scummvm-rg350-96d99c480be474eaa47df0976f9cd757acab460d.tar.gz scummvm-rg350-96d99c480be474eaa47df0976f9cd757acab460d.tar.bz2 scummvm-rg350-96d99c480be474eaa47df0976f9cd757acab460d.zip |
CGE: Add a safeguard in getPage()
Diffstat (limited to 'engines/cge')
-rw-r--r-- | engines/cge/fileio.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp index 8609110782..df5c31d367 100644 --- a/engines/cge/fileio.cpp +++ b/engines/cge/fileio.cpp @@ -77,7 +77,7 @@ ResourceManager::ResourceManager() { _buff[i]._page = new BtPage; _buff[i]._pageNo = kBtValNone; _buff[i]._index = -1; - assert(_buff[i]._page != NULL); + assert(_buff[i]._page != nullptr); } } @@ -118,6 +118,9 @@ uint16 ResourceManager::read(byte *buf, uint16 length) { BtPage *ResourceManager::getPage(int level, uint16 pageId) { debugC(1, kCGEDebugFile, "ResourceManager::getPage(%d, %d)", level, pageId); + if (level >= kBtLevel) + return nullptr; + if (_buff[level]._pageNo != pageId) { int32 pos = pageId * kBtSize; _buff[level]._pageNo = pageId; @@ -156,7 +159,6 @@ BtKeypack *ResourceManager::find(const char *key) { if (pg->_header._down != kBtValNone) { int i; for (i = 0; i < pg->_header._count; i++) { - // Does this work, or does it have to compare the entire buffer? if (scumm_strnicmp((const char *)key, (const char*)pg->_inner[i]._key, kBtKeySize) < 0) break; } |