From 0f13d56446a43c8af90e3422f6c0cddc509435fb Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 21 Apr 2005 05:15:04 +0000 Subject: [PATCH] fix "display_minventory: static object freed" panic (duplicate monster gold) From a bug report, using stone to flesh to reanimate a petrified monster who was carrying gold (in his case, it was a shopkeeper) resulted in gold in the monster's inventory. Somehow it was also being duplicated in the mgold field--I didn't try to figure that part out--so killing the monster produced double gold. More significantly, probing such a monster prior to killing it caused a panic when the monster inventory was being massaged for formatting. Fix is trivial: use a routine which knows about special handling for gold when transferring statue contents to resurrected monster. Both aspects of the problem only occurred for the !GOLDOBJ configuration (which is our default). However, any objects which confer something special when simply being carried would have also been misbehaving--automagic animation of cursed figurines is the only applicable situation; too rare for anyone to have noticed. --- doc/fixes34.4 | 2 ++ src/trap.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 853f90211..898e9cedb 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -115,6 +115,8 @@ when blinded hero detects a trap by touch, make sure it shows up on the map confused remove curse will cause loss of knowledge of items' curse/bless state with astral vision, the ";" command should only display "normal vision" for things that could be seen without astral vision +reanimating a statue containing gold produced double gold +probing the resulting double-gold monster caused "static object freed" panic Platform- and/or Interface-Specific Fixes diff --git a/src/trap.c b/src/trap.c index b20eb33cf..da7a34303 100644 --- a/src/trap.c +++ b/src/trap.c @@ -525,7 +525,7 @@ int *fail_reason; /* transfer any statue contents to monster's inventory */ while ((item = statue->cobj) != 0) { obj_extract_self(item); - (void) add_to_minv(mon, item); + (void) mpickobj(mon, item); } m_dowear(mon, TRUE); /* in case statue is wielded and hero zaps stone-to-flesh at self */