From 68b7693d98b2d269dccd3de8383a4d146bd63351 Mon Sep 17 00:00:00 2001 From: PatR <rankin@nethack.org> Date: Fri, 29 Jan 2016 17:14:42 -0800 Subject: [PATCH] crash fix 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 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/end.c b/src/end.c index 7e53467e7..b4a277b91 100644 --- 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) -- 2.40.0