SAGA2: Fix out-of-bounds read.. CID 1457984

This commit is contained in:
Eugene Sandulenko 2021-07-06 16:59:10 +02:00
parent a7650b1039
commit 42c888f8c8
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -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);