additonal oextra care

Be deliberately careful with copies taken of
oextra pointers and clear the pointer if it
truly is a redundant copy that will become
invalid if/when the original holder is deallocated.
This commit is contained in:
nethack.allison
2006-05-13 20:19:06 +00:00
parent 9151db8aaf
commit 1fcbfd85c9
6 changed files with 19 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)apply.c 3.5 2005/12/05 */
/* SCCS Id: @(#)apply.c 3.5 2006/05/13 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1997,6 +1997,9 @@ struct obj *tstone;
if (obj->oclass == COIN_CLASS) {
u.ugold += obj->quan; /* keep botl up to date */
goldobj = *obj;
goldobj.oextra = (struct oextra *)0; /* dealloc_obj(obj) will invalidate
the target of this copied ptr
here, so clear it out */
dealloc_obj(obj);
obj = &goldobj;
}