D97: clamp negative damagetype on PORT (US-build OOB read of g_DamageTypes)

bondviewPlayerTickDamageAndHealth computes damagetype = (s32)(health*8);
with health <= 0 (a lethal/near-lethal hit) that is negative and then
indexes g_DamageTypes[] below zero. N64 US absorbed the small OOB read;
on PC it segfaults (observed ~frame 5 in BUNKER1 when a guard shoots
Bond, fault ~0xff..401210e8). EU/JP already clamp negative to 0 right
here -- extend that clamp to PORT. N64 US build unchanged.
This commit is contained in:
James Dansereau committed 2026-08-28 16:35:25 -04:00
1 parent 1858b5d120
commit 66d64d047c
1 file changed
+6 -1
+6 -1
View File
@@ -6162,7 +6162,12 @@ void bondviewPlayerTickDamageAndHealth(void)
}
// Ensure we don't read out of bounds of the g_DamageTypes array.
#if defined(VERSION_EU) || defined(VERSION_JP)
#if defined(VERSION_EU) || defined(VERSION_JP) || defined(PORT)
/* D97: US has no low clamp -- a negative damagetype (health*8 with
* health <= 0, i.e. a lethal/near-lethal hit) then indexes
* g_DamageTypes[] below zero. N64 US absorbed the small OOB read;
* on PC it segfaults (observed ~frame 5 in BUNKER1 when a guard
* shoots Bond). EU/JP already clamp here -- do the same on PORT. */
if (g_CurrentPlayer->damagetype < 0)
{
g_CurrentPlayer->damagetype = 0;