[Scummvm-git-logs] scummvm master -> 9d0d57a35383fba140d5a05eb4b440e2937d1f4e

athrxx noreply at scummvm.org
Sat Jul 20 18:30:48 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9d0d57a353 KYRA: (EOB) - prevent invalid mem access


Commit: 9d0d57a35383fba140d5a05eb4b440e2937d1f4e
    https://github.com/scummvm/scummvm/commit/9d0d57a35383fba140d5a05eb4b440e2937d1f4e
Author: athrxx (athrxx at scummvm.org)
Date: 2024-07-20T20:30:29+02:00

Commit Message:
KYRA: (EOB) - prevent invalid mem access

The return from getCharacterClassType() can be -1. I don't
think it really happens but it will for sure trigger the static
analyzers

Changed paths:
    engines/kyra/engine/eobcommon.cpp


diff --git a/engines/kyra/engine/eobcommon.cpp b/engines/kyra/engine/eobcommon.cpp
index 21b6a234309..08574a0d5c1 100644
--- a/engines/kyra/engine/eobcommon.cpp
+++ b/engines/kyra/engine/eobcommon.cpp
@@ -1040,10 +1040,10 @@ int EoBCoreEngine::generateCharacterHitpointsByLevel(int charIndex, int levelInd
 
 		int d = getCharacterClassType(c->cClass, i);
 
-		if (c->level[i] <= _hpIncrPerLevel[6 + d])
+		if (c->level[i] <= (d >= 0 ? _hpIncrPerLevel[6 + d] : 0))
 			h += rollDice(1, (d >= 0) ? _hpIncrPerLevel[d] : 0);
 		else
-			h += _hpIncrPerLevel[12 + d];
+			h += (d >= 0 ?_hpIncrPerLevel[12 + d] : 0);
 
 		h += m;
 	}




More information about the Scummvm-git-logs mailing list