aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1/resman.cpp
diff options
context:
space:
mode:
authorThierry Crozat2013-04-24 21:24:45 +0100
committerThierry Crozat2013-04-24 21:24:58 +0100
commitff1bdc7f5840e2d281f99cd2f74144a5473a180f (patch)
tree53f9f0bf91b9cb9d8294dbdba8d9f5338b79a221 /engines/sword1/resman.cpp
parent621364edaef3a10618b62a2424ba775c2380c23d (diff)
downloadscummvm-rg350-ff1bdc7f5840e2d281f99cd2f74144a5473a180f.tar.gz
scummvm-rg350-ff1bdc7f5840e2d281f99cd2f74144a5473a180f.tar.bz2
scummvm-rg350-ff1bdc7f5840e2d281f99cd2f74144a5473a180f.zip
SWORD1: Avoid possible dereferencing of a null pointer
CID 1003605
Diffstat (limited to 'engines/sword1/resman.cpp')
-rw-r--r--engines/sword1/resman.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/engines/sword1/resman.cpp b/engines/sword1/resman.cpp
index 878ba8eceb..3e8ee93c52 100644
--- a/engines/sword1/resman.cpp
+++ b/engines/sword1/resman.cpp
@@ -227,7 +227,8 @@ Header *ResMan::lockScript(uint32 scrID) {
#else
openScriptResourceLittleEndian(scrID);
#endif
- return (Header *)resHandle(scrID)->data;
+ MemHandle *handle = resHandle(scrID);
+ return handle != NULL ? (Header *)handle->data : NULL;
}
void ResMan::unlockScript(uint32 scrID) {
@@ -343,8 +344,8 @@ MemHandle *ResMan::resHandle(uint32 id) {
uint8 cluster = (uint8)((id >> 24) - 1);
uint8 group = (uint8)(id >> 16);
- // There is a know case of reading beyond array boundaries when trying to use
- // portuguese subtitles (cluster file 2, group 6) with a version that do not
+ // There is a known case of reading beyond array boundaries when trying to use
+ // portuguese subtitles (cluster file 2, group 6) with a version that does not
// contain subtitles for this languages (i.e. has only 6 languages and not 7).
if (cluster >= _prj.noClu || group >= _prj.clu[cluster].noGrp)
return NULL;