DIRECTOR: LINGO: Fix constant size check

This commit is contained in:
Scott Percival 2020-01-17 20:36:21 +08:00
parent e8ad1bdec5
commit 329b77bd82

View File

@ -494,14 +494,14 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
constant.type = STRING; constant.type = STRING;
constant.u.s = new Common::String(); constant.u.s = new Common::String();
uint32 pointer = value; uint32 pointer = value;
if (pointer + 4 >= constsStoreSize) { if (pointer + 4 > constsStoreSize) {
error("Constant string is too small"); error("Constant string is too small");
break; break;
} }
uint32 length = READ_BE_UINT32(&constsStore[pointer]); uint32 length = READ_BE_UINT32(&constsStore[pointer]);
pointer += 4; pointer += 4;
uint32 end = pointer + length; uint32 end = pointer + length;
if (end >= constsStoreSize) { if (end > constsStoreSize) {
error("Constant string is too large"); error("Constant string is too large");
break; break;
} }
@ -515,7 +515,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
} }
pointer += 1; pointer += 1;
} }
if (pointer >= constsStoreSize) { if (pointer > constsStoreSize) {
warning("Constant string has no null terminator"); warning("Constant string has no null terminator");
break; break;
} }