]> granicus.if.org Git - nethack/commitdiff
crash fix
authorPatR <rankin@nethack.org>
Sat, 30 Jan 2016 01:14:42 +0000 (17:14 -0800)
committerPatR <rankin@nethack.org>
Sat, 30 Jan 2016 01:14:42 +0000 (17:14 -0800)
After the recent shopkeeper fix, I wanted to find out what happens if
you turn to stone in the spot inside the shop door.  It didn't go too
well--a change of mine from three weeks ago caused a crash due to
passing a null pointer to strcmp().  Death from being turned to stone
or from starvation when there was no while-helpless reason (probably
not possible for starving) triggered it.  This fixes that.

As far as the test goes, the shopkeeper takes your inventory and moves
it all the way into the shop, and a statue of the petrified hero is
left without contents in the spot in front of the door.  That shk was
awfully quick....

Post-3.6.0 bug, so no fixes entry.

src/end.c

index 7e53467e71d0c32afc44d2ab299822aa63d30d35..b4a277b91ddf62bfd56d7bb3df90cac58f6b355f 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 end.c   $NHDT-Date: 1450432758 2015/12/18 09:59:18 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.111 $ */
+/* NetHack 3.6 end.c   $NHDT-Date: 1454116472 2016/01/30 01:14:32 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.113 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -526,17 +526,19 @@ int how;
 {
     int i;
 
-    for (i = 0; i < SIZE(death_fixups); ++i)
-        if (death_fixups[i].why == how
-            && !strcmp(death_fixups[i].exclude, multi_reason)) {
-            if (death_fixups[i].include) /* substitute an alternate reason */
-                multi_reason = death_fixups[i].include;
-            else /* remove the helplessness reason */
-                multi_reason = (char *) 0;
-            if (death_fixups[i].unmulti) /* possibly hide helplessness */
-                multi = 0L;
-            break;
-        }
+    if (multi_reason) {
+        for (i = 0; i < SIZE(death_fixups); ++i)
+            if (death_fixups[i].why == how
+                && !strcmp(death_fixups[i].exclude, multi_reason)) {
+                if (death_fixups[i].include) /* substitute alternate reason */
+                    multi_reason = death_fixups[i].include;
+                else /* remove the helplessness reason */
+                    multi_reason = (char *) 0;
+                if (death_fixups[i].unmulti) /* possibly hide helplessness */
+                    multi = 0L;
+                break;
+            }
+    }
 }
 
 #if defined(WIN32) && !defined(SYSCF)