fix suicidal panic

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.)
This commit is contained in:
nethack.rankin
2007-12-03 21:13:58 +00:00
parent 19d9b34374
commit 3e42f76244
+3 -1
View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -873,10 +873,12 @@ boolean hitsroof;
Strcpy(killer.name, "elementary physics"); /* "what goes up..." */ Strcpy(killer.name, "elementary physics"); /* "what goes up..." */
You("turn to stone."); You("turn to stone.");
if (obj) dropy(obj); /* bypass most of hitfloor() */ if (obj) dropy(obj); /* bypass most of hitfloor() */
thrownobj = 0; /* now either gone or on floor */
done(STONING); done(STONING);
return obj ? TRUE : FALSE; return obj ? TRUE : FALSE;
} }
hitfloor(obj); hitfloor(obj);
thrownobj = 0;
losehp(Maybe_Half_Phys(dmg), "falling object", KILLED_BY_AN); losehp(Maybe_Half_Phys(dmg), "falling object", KILLED_BY_AN);
} }
return TRUE; return TRUE;