mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Add bounds checks to indexing of global "temporary" variable k
For some reason, the variable `k` is on entityclass and gets mutated in createentity() and createblock(). Then updateentities() uses it without checking if it's valid, because either `k` or the size of `entities` could have changed in the meantime. To fix any potential undefined behavior, these bounds checks should be added.
This commit is contained in:
parent
990ee63a6e
commit
a38faad156
1 changed files with 2 additions and 2 deletions
|
@ -2736,8 +2736,8 @@ bool entityclass::updateentities( int i )
|
|||
if (entities[i].state == 1)
|
||||
{
|
||||
//happy!
|
||||
if (entities[k].rule == 6) entities[k].tile = 0;
|
||||
if (entities[k].rule == 7) entities[k].tile = 6;
|
||||
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 6) entities[k].tile = 0;
|
||||
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 7) entities[k].tile = 6;
|
||||
//Stay close to the hero!
|
||||
int j = getplayer();
|
||||
if (INBOUNDS_VEC(j, entities) && entities[j].xp > entities[i].xp + 5)
|
||||
|
|
Loading…
Reference in a new issue