fix memory leak: obj->oextra->omonst->mextra
The memory leak (monst->mextra->edog, monst->mextra->mname, monst->mextra for some monster were not released) I noticed recently was due to recording a pet's full monster attributes with its corpse. During save and restore, obj->oextra->omonst was being treated as a full-fledged monster so worked as intended, but when freed, omonst was treated as a black box and its mextra details weren't handled.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 zap.c $NHDT-Date: 1446887542 2015/11/07 09:12:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.233 $ */
|
||||
/* NetHack 3.6 zap.c $NHDT-Date: 1447475947 2015/11/14 04:39:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.235 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -4462,9 +4462,8 @@ register struct obj *obj; /* no texts here! */
|
||||
obj->owt = weight(obj);
|
||||
obj->dknown = obj->bknown = obj->rknown = 0;
|
||||
obj->known = objects[obj->otyp].oc_uses_known ? 0 : 1;
|
||||
if (obj->oextra)
|
||||
dealloc_oextra(obj->oextra);
|
||||
obj->oextra = (struct oextra *) 0;
|
||||
dealloc_oextra(obj);
|
||||
|
||||
if (obj->where == OBJ_FLOOR) {
|
||||
obj_extract_self(obj); /* move rocks back on top */
|
||||
place_object(obj, obj->ox, obj->oy);
|
||||
|
||||
Reference in New Issue
Block a user