]> granicus.if.org Git - nethack/commitdiff
missile vs engulfer (trunk only)
authornethack.rankin <nethack.rankin>
Tue, 30 Jun 2009 08:22:40 +0000 (08:22 +0000)
committernethack.rankin <nethack.rankin>
Tue, 30 Jun 2009 08:22:40 +0000 (08:22 +0000)
     Noticed while testing the "<obj> is no longer poisoned" fix; killing
an engulfer via "the poison was deadly..." led to an "obj not free" panic.
It was due to post-3.4.3 changes, so no fixes entry.

src/dothrow.c

index 979d7993bf9d490add3b7218ba04f67eedcdb883..fc7af5735fe20f772d35e703a418a91ebb6434ef 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 dothrow.c       $Date$  $Revision$ */
-/*     SCCS Id: @(#)dothrow.c  3.5     2009/01/22      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1416,6 +1415,11 @@ register struct obj *obj;        /* thrownobj or kickobj or uwep */
                    cutworm(mon, bhitpos.x, bhitpos.y, obj);
                }
                exercise(A_DEX, TRUE);
+               /* if hero is swallowed and projectile kills the engulfer,
+                  obj gets added to engulfer's inventory and then dropped,
+                  so we can't safely use that pointer anymore; it escapes
+                  the chance to be used up here... */
+               if (!thrownobj) return 1;
                /* projectiles other than magic stones
                   sometimes disappear when thrown */
                if (objects[otyp].oc_skill < P_NONE &&