fix #K763 - segfault eating tin of Rider meat
Eating a tin of one of the Riders and being life-saved or declining to die would crash when trying to revive a non-existent corpse. An old comment stated that since such tins were impossible it could assume that it was dealing with a corpse, but wishing for tins of the Riders is possible in wizard mode. They can't be passed along to normal mode via bones because they're changed to empty tins as bones are saved. So there doesn't seem to be much point in allowing wizard mode wishing to create them, but I've left that as is.
This commit is contained in:
18
src/eat.c
18
src/eat.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 eat.c $NHDT-Date: 1584405116 2020/03/17 00:31:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.223 $ */
|
||||
/* NetHack 3.6 eat.c $NHDT-Date: 1586303701 2020/04/07 23:55:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.225 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -712,10 +712,13 @@ register int pm;
|
||||
done(DIED);
|
||||
/* life-saving needed to reach here */
|
||||
exercise(A_WIS, FALSE);
|
||||
/* It so happens that since we know these monsters */
|
||||
/* cannot appear in tins, g.context.victual.piece will always */
|
||||
/* be what we want, which is not generally true. */
|
||||
if (revive_corpse(g.context.victual.piece)) {
|
||||
/* revive an actual corpse; can't do that if it was a tin;
|
||||
3.7: this used to assume that such tins were impossible but
|
||||
they can be wished for in wizard mode; they can't make it
|
||||
to normal play though because bones creation empties them */
|
||||
if (g.context.victual.piece /* Null for tins */
|
||||
&& g.context.victual.piece->otyp == CORPSE /* paranoia */
|
||||
&& revive_corpse(g.context.victual.piece)) {
|
||||
g.context.victual.piece = (struct obj *) 0;
|
||||
g.context.victual.o_id = 0;
|
||||
}
|
||||
@@ -1075,6 +1078,11 @@ int pm;
|
||||
debugpline0("using attrcurse to strip an intrinsic");
|
||||
attrcurse();
|
||||
break;
|
||||
case PM_DEATH:
|
||||
case PM_PESTILENCE:
|
||||
case PM_FAMINE:
|
||||
/* life-saved; don't attempt to confer any intrinsics */
|
||||
break;
|
||||
case PM_MIND_FLAYER:
|
||||
case PM_MASTER_MIND_FLAYER:
|
||||
if (ABASE(A_INT) < ATTRMAX(A_INT)) {
|
||||
|
||||
Reference in New Issue
Block a user