]> granicus.if.org Git - nethack/commitdiff
Fix segfault with uball
authorPasi Kallinen <paxed@alt.org>
Sat, 5 Mar 2022 08:06:01 +0000 (10:06 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 5 Mar 2022 08:09:54 +0000 (10:09 +0200)
Drowning in a pool while punished and carrying the ball,
and the only available space to crawl back on dry land
has a magic trap, which unpunishes you.

src/teleport.c

index baae6f350dc9c1764cf2e80aa149ab9ee6b69b76..37bbcdef9a82e45a5de8d685ca74cf95ee6926c9 100644 (file)
@@ -365,8 +365,14 @@ teleds(int nux, int nuy, int teleds_flags)
         if (drag_ball(nux, nuy, &bc_control, &ballx, &bally, &chainx,
                       &chainy, &cause_delay, allow_drag))
             move_bc(0, bc_control, ballx, bally, chainx, chainy);
-        else /* dragging fails if hero is encumbered beyond 'burdened' */
-            unplacebc(); /* to match placebc() below */
+        else {
+            /* dragging fails if hero is encumbered beyond 'burdened' */
+            /* uball might've been cleared via drag_ball -> spoteffects ->
+               dotrap -> magic trap unpunishment */
+            ball_active = (Punished && uball->where != OBJ_FREE);
+            if (ball_active)
+                unplacebc(); /* to match placebc() below */
+        }
     }
 
     /* must set u.ux, u.uy after drag_ball(), which may need to know