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
This commit is contained in:
terminx 2019-04-18 17:23:38 +00:00 committed by Christoph Oelckers
parent a32597464f
commit e5c979c997

View file

@ -4913,7 +4913,10 @@ badindex:
Gv_FillWithVars(vect); Gv_FillWithVars(vect);
int const returnVar = *insptr++; 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, &sectNum); updatesector(vect.x, vect.y, &sectNum);
Gv_SetVarX(returnVar, sectNum); Gv_SetVarX(returnVar, sectNum);
@ -4927,7 +4930,10 @@ badindex:
Gv_FillWithVars(vect); Gv_FillWithVars(vect);
int const returnVar = *insptr++; 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, &sectNum); updatesectorz(vect.x, vect.y, vect.z, &sectNum);
Gv_SetVarX(returnVar, sectNum); Gv_SetVarX(returnVar, sectNum);