From ff1bdc7f5840e2d281f99cd2f74144a5473a180f Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Wed, 24 Apr 2013 21:24:45 +0100 Subject: SWORD1: Avoid possible dereferencing of a null pointer CID 1003605 --- engines/sword1/resman.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/sword1/resman.cpp') 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; -- cgit v1.2.3