[Scummvm-cvs-logs] scummvm master -> 690c6cc8d49293a295e56eeace9007450e5af14c
Strangerke
Strangerke at scummvm.org
Fri Sep 26 23:44:50 CEST 2014
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b5ad4eedb3 CGE2: Fix a crash when detecting an empty set of VOL files
690c6cc8d4 CGE: Fix a crash when detecting an empty set of VOL files
Commit: b5ad4eedb3cb011eb6a03a131b9ef7cd1afd47cd
https://github.com/scummvm/scummvm/commit/b5ad4eedb3cb011eb6a03a131b9ef7cd1afd47cd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-26T23:41:31+02:00
Commit Message:
CGE2: Fix a crash when detecting an empty set of VOL files
Changed paths:
engines/cge2/fileio.cpp
diff --git a/engines/cge2/fileio.cpp b/engines/cge2/fileio.cpp
index 6f80097..acb5bb8 100644
--- a/engines/cge2/fileio.cpp
+++ b/engines/cge2/fileio.cpp
@@ -116,7 +116,10 @@ BtPage *ResourceManager::getPage(int level, uint16 pageId) {
if (_buff[level]._pageNo != pageId) {
int32 pos = pageId * kBtSize;
_buff[level]._pageNo = pageId;
- assert(_catFile->size() > pos);
+
+ if (_catFile->size() <= pos)
+ return nullptr;
+
// In the original, there was a check verifying if the
// purpose was to write a new file. This should only be
// to create a new file, thus it was removed.
@@ -139,6 +142,9 @@ BtKeypack *ResourceManager::find(const char *key) {
uint16 nxt = kBtValRoot;
while (!_catFile->eos()) {
BtPage *pg = getPage(lev, nxt);
+ if (!pg)
+ return nullptr;
+
// search
if (pg->_header._down != kBtValNone) {
int i;
@@ -170,7 +176,11 @@ BtKeypack *ResourceManager::find(const char *key) {
}
bool ResourceManager::exist(const char *name) {
- return scumm_stricmp(find(name)->_key, name) == 0;
+ BtKeypack *result = find(name);
+ if (!result)
+ return false;
+
+ return scumm_stricmp(result->_key, name) == 0;
}
uint16 ResourceManager::catRead(byte *buf, uint16 length) {
Commit: 690c6cc8d49293a295e56eeace9007450e5af14c
https://github.com/scummvm/scummvm/commit/690c6cc8d49293a295e56eeace9007450e5af14c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-26T23:41:51+02:00
Commit Message:
CGE: Fix a crash when detecting an empty set of VOL files
Changed paths:
engines/cge/detection.cpp
engines/cge/fileio.cpp
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index ee67fb8..da5eb2b 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -157,7 +157,7 @@ const ADGameDescription *CGEMetaEngine::fallbackDetect(const FileMap &allFiles,
game = detectGameFilebased(allFiles, fslist, CGE::fileBasedFallback, &filesProps);
if (!game)
- return 0;
+ return nullptr;
SearchMan.clear();
SearchMan.addDirectory(fslist.begin()->getParent().getPath(), fslist.begin()->getParent());
@@ -167,7 +167,7 @@ const ADGameDescription *CGEMetaEngine::fallbackDetect(const FileMap &allFiles,
delete resman;
if (!result)
- return 0;
+ return nullptr;
reportUnknown(fslist.begin()->getParent(), filesProps);
return &s_fallbackDesc;
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index d910e27..8609110 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -121,7 +121,10 @@ BtPage *ResourceManager::getPage(int level, uint16 pageId) {
if (_buff[level]._pageNo != pageId) {
int32 pos = pageId * kBtSize;
_buff[level]._pageNo = pageId;
- assert(_catFile->size() > pos);
+
+ if (_catFile->size() <= pos)
+ return nullptr;
+
// In the original, there was a check verifying if the
// purpose was to write a new file. This should only be
// to create a new file, thus it was removed.
@@ -146,6 +149,9 @@ BtKeypack *ResourceManager::find(const char *key) {
uint16 nxt = kBtValRoot;
while (!_catFile->eos()) {
BtPage *pg = getPage(lev, nxt);
+ if (!pg)
+ return nullptr;
+
// search
if (pg->_header._down != kBtValNone) {
int i;
@@ -167,13 +173,17 @@ BtKeypack *ResourceManager::find(const char *key) {
return &pg->_leaf[i];
}
}
- return NULL;
+ return nullptr;
}
bool ResourceManager::exist(const char *name) {
debugC(1, kCGEDebugFile, "ResourceManager::exist(%s)", name);
- return scumm_stricmp(find(name)->_key, name) == 0;
+ BtKeypack* result = find(name);
+ if (!result)
+ return false;
+
+ return scumm_stricmp(result->_key, name) == 0;
}
uint16 ResourceManager::catRead(byte *buf, uint16 length) {
More information about the Scummvm-git-logs
mailing list