]> granicus.if.org Git - nethack/commitdiff
fix #K763 - segfault eating tin of Rider meat
authorPatR <rankin@nethack.org>
Tue, 7 Apr 2020 23:55:07 +0000 (16:55 -0700)
committerPatR <rankin@nethack.org>
Tue, 7 Apr 2020 23:55:07 +0000 (16:55 -0700)
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.

doc/fixes37.0
src/eat.c

index 44ecccd088f495aeb4086ec0310961196c41d988..436623863fcd612e1feaefd379cf7339d476a306 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.168 $ $NHDT-Date: 1586285681 2020/04/07 18:54:41 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.169 $ $NHDT-Date: 1586303701 2020/04/07 23:55:01 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -122,6 +122,8 @@ object taking erosion damage might give feedback message when out of view
        or not give such when in view, depending on stale value of 'bhitpos'
        [cited case assumed message came from drowned monster's dropped
        inventory when out-of-view ice melted]
+it's possible to wish for tins of the Riders in wizard mode; eating one is
+       fatal but if you're life-saved or decline to die, the game crashed
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index bf145f02e96eac9dbdaa5ad3eaf9b0d29c27c904..f168ad62d21dd65fa0b4e5270def7d7dabeb1b51 100644 (file)
--- a/src/eat.c
+++ b/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)) {