@@ -7893,7 +7893,7 @@ int32_t get_register(const int32_t arg)
7893
7893
if ( indx < 0 || indx > 31 )
7894
7894
{
7895
7895
ret = -10000;
7896
- Z_scripterrlog("Invalud index used to access Game->Misc: %d\n", indx);
7896
+ Z_scripterrlog("Invalid index used to access Game->Misc: %d\n", indx);
7897
7897
}
7898
7898
else
7899
7899
{
@@ -7913,14 +7913,23 @@ int32_t get_register(const int32_t arg)
7913
7913
int32_t inx = (ri->d[rINDEX])/10000;
7914
7914
if ( (unsigned) inx > (susptLAST-1) )
7915
7915
{
7916
- Z_scripterrlog("Invalid array index [%d] passed to Gme ->Suspend[]\n");
7916
+ Z_scripterrlog("Invalid array index [%d] passed to Game ->Suspend[]\n");
7917
7917
}
7918
7918
ret = (( FFCore.system_suspend[inx] ) ? 10000 : 0);
7919
7919
break;
7920
7920
}
7921
7921
case GAMELITEMSD:
7922
- ret=game->lvlitems[(ri->d[rINDEX])/10000]*10000;
7922
+ {
7923
+ size_t index = ri->d[rINDEX] / 10000;
7924
+ if (index >= game->lvlitems.size())
7925
+ {
7926
+ ret = 0;
7927
+ Z_scripterrlog("Invalid array index [%d] passed to Game->LItems[]\n", index);
7928
+ break;
7929
+ }
7930
+ ret=game->lvlitems[index]*10000;
7923
7931
break;
7932
+ }
7924
7933
case GAMELSWITCH:
7925
7934
{
7926
7935
int32_t ind = (ri->d[rINDEX])/10000;
@@ -20877,15 +20886,20 @@ void set_register(int32_t arg, int32_t value)
20877
20886
int32_t inx = (ri->d[rINDEX])/10000;
20878
20887
if ( (unsigned) inx > (susptLAST-1) )
20879
20888
{
20880
- Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
20889
+ Z_scripterrlog("Invalid array index [%d] passed to Game->Suspend[]\n");
20890
+ break;
20881
20891
}
20882
20892
FFCore.system_suspend[inx]= ( (value) ? 1 : 0 );
20883
20893
break;
20884
20894
}
20885
20895
20886
20896
case GAMELITEMSD:
20887
- game->lvlitems[(ri->d[rINDEX])/10000]=value/10000;
20897
+ {
20898
+ int32_t ind = (ri->d[rINDEX])/10000;
20899
+ if(unsigned(ind) < MAXLEVELS)
20900
+ game->lvlitems[ind]=value/10000;
20888
20901
break;
20902
+ }
20889
20903
case GAMELSWITCH:
20890
20904
{
20891
20905
int32_t ind = (ri->d[rINDEX])/10000;
0 commit comments