exploding magic pointers

Fix the two problems that <Someone> reported about stale pointer use
after a bag of holding has exploded.  use_container() passed the wrong
variable for quantity when calling useupf(), and doapply() had no way to
tell if the object being used had been destroyed so could use an invalid
pointer when checking for speaking artifact.  The fix for the latter is
much simpler than what <Someone> suggested.
This commit is contained in:
nethack.rankin
2005-02-06 03:25:04 +00:00
parent 5ff9b37ba4
commit 8414b5214f
3 changed files with 16 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)apply.c 3.5 2004/12/21 */
/* SCCS Id: @(#)apply.c 3.5 2005/01/05 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -45,6 +45,9 @@ STATIC_DCL void FDECL(add_class, (char *, CHAR_P));
void FDECL( amii_speaker, ( struct obj *, char *, int ) );
#endif
/* managed by use_container(pickup.c) */
extern struct obj *current_container;
static const char no_elbow_room[] = "don't have enough elbow-room to maneuver.";
#ifdef TOURIST
@@ -2967,6 +2970,9 @@ doapply()
case BAG_OF_HOLDING:
case OILSKIN_SACK:
res = use_container(obj, 1);
/* magic bag might end up being destroyed;
if so, current_container will be null */
obj = current_container;
break;
case BAG_OF_TRICKS:
bagotricks(obj);