Fix squeaky board creation segfault
If a trap is created on top of another trap, maketrap reuses the trap struct in place, instead of deleting and recreating it. If a squeaky trap was created on top of another trap, maketrap first set the trap type to squeaky board, and then tried to look through all squeaky boards on the level, to determine what note the new trap should play. Unfortunately, the union with the trap note most likely contained a rolling boulder coordinate or something else outside the 12 note range, so then the tavail-array lookup would cause a segfault.
This commit is contained in:
@@ -339,7 +339,7 @@ register int x, y, typ;
|
||||
for (k = 0; k < 12; ++k)
|
||||
tavail[k] = 0;
|
||||
for (t = ftrap; t; t = t->ntrap)
|
||||
if (t->ttyp == SQKY_BOARD)
|
||||
if (t->ttyp == SQKY_BOARD && t != ttmp)
|
||||
tavail[t->tnote] = 1;
|
||||
|
||||
/* Now populate tpick with the available indexes */
|
||||
|
||||
Reference in New Issue
Block a user