Long worm may get killed in middle of action

If long worm attacks you, and you have a passive response that may
kill the worm (eg. blue jelly), the worm may die in the middle of
a loop checking for a worm segment that can attack. This'll cause
a segfault because the worm segments will get freed.

If the worm dies, just exit the loop.
This commit is contained in:
Pasi Kallinen
2018-11-19 21:27:19 +02:00
parent 9ad7268c0a
commit 7119baafb8

View File

@@ -301,7 +301,8 @@ register struct monst *worm;
*/
for (seg = wtails[wnum]; seg; seg = seg->nseg)
if (distu(seg->wx, seg->wy) < 3)
(void) mattacku(worm);
if (mattacku(worm))
return; /* your passive ability killed the worm */
}
/* cutworm()