From e5c979c997cc5886a84cae11fc1bf96c994bed12 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 18 Apr 2019 17:23:38 +0000 Subject: [PATCH] CON_UPDATESECTOR/CON_UPDATESECTORZ: only use sprite[vm.spriteNum].sectnum if the initial value of the input/output parameter is outside the range of 0 - MAXSECTORS-1 git-svn-id: https://svn.eduke32.com/eduke32@7579 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gameexec.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index f6bafd129..f798294a2 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -4913,7 +4913,10 @@ badindex: Gv_FillWithVars(vect); int const returnVar = *insptr++; - int16_t sectNum = sprite[vm.spriteNum].sectnum; + int16_t sectNum = Gv_GetVarX(returnVar); + + if ((unsigned)sectNum >= MAXSECTORS) + sectNum = sprite[vm.spriteNum].sectnum; updatesector(vect.x, vect.y, §Num); Gv_SetVarX(returnVar, sectNum); @@ -4927,7 +4930,10 @@ badindex: Gv_FillWithVars(vect); int const returnVar = *insptr++; - int16_t sectNum = sprite[vm.spriteNum].sectnum; + int16_t sectNum = Gv_GetVarX(returnVar); + + if ((unsigned)sectNum >= MAXSECTORS) + sectNum = sprite[vm.spriteNum].sectnum; updatesectorz(vect.x, vect.y, vect.z, §Num); Gv_SetVarX(returnVar, sectNum);