From 7119baafb8f239208b4b9e7ecda157fbe627044c Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 19 Nov 2018 21:27:19 +0200 Subject: [PATCH] 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. --- src/worm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/worm.c b/src/worm.c index c99787461..2a19df288 100644 --- a/src/worm.c +++ b/src/worm.c @@ -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() -- 2.40.0