From 42c888f8c81f3b83caab7305d1ba42c7ecb60c6b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 6 Jul 2021 16:59:10 +0200 Subject: [PATCH] SAGA2: Fix out-of-bounds read.. CID 1457984 --- engines/saga2/magic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp index 6a6117e46a8..9c360b53781 100644 --- a/engines/saga2/magic.cpp +++ b/engines/saga2/magic.cpp @@ -95,15 +95,15 @@ GameObject *GetOwner(GameObject *go) { // This call looks up a spells object prototype. It can accept either // an object ID or a spell ID SkillProto *skillProtoFromID(int16 spellOrObjectID) { - if (spellOrObjectID > MAX_SPELLS) - return (SkillProto *) GameObject::protoAddress(spellOrObjectID); + if (spellOrObjectID >= MAX_SPELLS) + return (SkillProto *)GameObject::protoAddress(spellOrObjectID); return spellBook[spellOrObjectID].getProto(); } //----------------------------------------------------------------------- // initialization call to connect skill prototypes with their spells void initializeSkill(SkillProto *oNo, SpellID sNo) { - if (sNo > 0 && sNo <= MAX_SPELLS - 1) { + if (sNo > 0 && sNo < MAX_SPELLS) { if (spellBook[sNo].getProto() != NULL) error("Duplicate prototype for spell %d", sNo); spellBook[sNo].setProto(oNo);