From e4fb67bc25a7833531f2e216458936f944099688 Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Sun, 25 Jul 2021 02:00:35 +0100 Subject: [PATCH] Rides Again: Possible array index by -1 in Proj_DoHitscan(). Added check to prevent this. --- source/games/duke/src/player_r.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index abfd3daa5..269ede057 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -111,7 +111,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, bsin(sa), zvel << 6, &hitsect, &hitwall, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); - if (isRRRA() && ((sector[hitsect].lotag == 160 && zvel > 0) || (sector[hitsect].lotag == 161 && zvel < 0)) + if (isRRRA() && hitsect >= 0 && ((sector[hitsect].lotag == 160 && zvel > 0) || (sector[hitsect].lotag == 161 && zvel < 0)) && hitsprt == nullptr && hitwall == -1) { DukeLinearSpriteIterator its; @@ -268,7 +268,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa hitscan(sx, sy, sz, sect, bcos(sa), bsin(sa), zvel << 6, &hitsect, &hitwall, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); - if (isRRRA() && (((sector[hitsect].lotag == 160 && zvel > 0) || (sector[hitsect].lotag == 161 && zvel < 0)) + if (isRRRA() && hitsect >= 0 && (((sector[hitsect].lotag == 160 && zvel > 0) || (sector[hitsect].lotag == 161 && zvel < 0)) && hitsprt == nullptr && hitwall == -1)) { DukeLinearSpriteIterator its;