shithub: duke3d

Download patch

ref: de2d60828c09de9e0d7b6f2c24c92d828a0a5fe3
parent: bef0add179564dcba03c8f66b648a7bf07400295
author: Rohit Nirmal <rohitnirmal9@gmail.com>
date: Fri Mar 20 09:36:05 EDT 2015

64-bit: Add bounds check in weapon switching.
j is usually 0 - 11 during regular gameplay,
but is > 4 billion at one point during the
demo. On 32-bit, this doesn't segfault. The
demo now plays to completion.

--- a/Game/src/sector.c
+++ b/Game/src/sector.c
@@ -2712,7 +2712,7 @@
                     sb_snum |= 1<<19;
                     p->weapon_pos = -9;
                 }
-                else if( p->gotweapon[j] && p->curr_weapon != j ) switch(j)
+                else if(j < MAX_WEAPONS && p->gotweapon[j] && p->curr_weapon != j ) switch(j)
                 {
                     case KNEE_WEAPON:
                         addweapon( p, KNEE_WEAPON );