]> granicus.if.org Git - nethack/commitdiff
fix suicidal panic
authornethack.rankin <nethack.rankin>
Mon, 3 Dec 2007 21:13:58 +0000 (21:13 +0000)
committernethack.rankin <nethack.rankin>
Mon, 3 Dec 2007 21:13:58 +0000 (21:13 +0000)
     Some post-3.4.3 code in done() cleans up thrownobj and kickobj to
plug a potential memory leak (unnoticeable one since the game is over),
but they have to be free objects rather than on any list.  toss_up() was
leaving thrownobj defined after putting the thrown object on the floor,
leading to "obj not free" panic from dealloc_obj() if threw you an object
upward and it dealt fatal damage when it fell back down.  (For non-fatal
damage, toss_up()'s caller cleaned things up later.)

src/dothrow.c

index 26be01f61ea6dcf1e130cc8b7eac2d4b2765fccd..ef6fc79822bca2e37ec8de1db8c823291dc2253d 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dothrow.c  3.5     2007/03/23      */
+/*     SCCS Id: @(#)dothrow.c  3.5     2007/12/03      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -873,10 +873,12 @@ boolean hitsroof;
            Strcpy(killer.name, "elementary physics"); /* "what goes up..." */
            You("turn to stone.");
            if (obj) dropy(obj);        /* bypass most of hitfloor() */
+           thrownobj = 0;              /* now either gone or on floor */
            done(STONING);
            return obj ? TRUE : FALSE;
        }
        hitfloor(obj);
+       thrownobj = 0;
        losehp(Maybe_Half_Phys(dmg), "falling object", KILLED_BY_AN);
     }
     return TRUE;