From 3e42f762445a56df1c23459c31cec67d80271064 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Mon, 3 Dec 2007 21:13:58 +0000 Subject: [PATCH] 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.) --- src/dothrow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dothrow.c b/src/dothrow.c index 26be01f61..ef6fc7982 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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;