diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 1f281f47c..aa27902a7 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1602,6 +1602,7 @@ when starting a new game as a monk, newsym(0,0) was being called (adjabil -> postadjabil -> see_monsters when initializing See_invisible as hero became level 1; seen 'monster' was the hero who hadn't been placed on the map yet) +incorporate a fix to prevent segfault due to rolling boulder trap Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/trap.c b/src/trap.c index cc62fdd3e..a97706fe8 100644 --- a/src/trap.c +++ b/src/trap.c @@ -3375,6 +3375,23 @@ launch_obj( while (tmp-- > 0) nh_delay_output(); + /* + * TEMPORARY? github issue #1490 by BartekCupial reports a + * segfault when boulder rolls out of bounds. That should be + * impossible because trap creation validates the path that + * the boulder will traverse. + * + * The suggested fix increments bhitpos, verifies with isok(), + * then undoes the increment if not ok. This is simpler. + */ + if (!isok(gb.bhitpos.x + dx, gb.bhitpos.y + dy)) { + x2 = x, y2 = y; /* use current spot for final boulder placement */ + break; + } + /* + * end TEMPORARY? + */ + x = (gb.bhitpos.x += dx); y = (gb.bhitpos.y += dy);