From 3924b01e73dd6f93220b6d4d0c1d2642a32aa218 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 27 Apr 2015 23:42:06 -0400 Subject: [PATCH] trade a segfault for a panic Changes to be committed: modified: src/invent.c modified: src/options.c Apparently we need this based on Pasi's segfault. We just don't yet know why we need them. Also fix a warning: ..\src\options.c(1282) : warning C4101: 'tmp' : unreferenced local variable --- src/invent.c | 5 +++++ src/options.c | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/invent.c b/src/invent.c index b1aee908b..176d2b8d2 100644 --- a/src/invent.c +++ b/src/invent.c @@ -395,6 +395,7 @@ addinv(obj) struct obj *obj; { struct obj *otmp, *prev; + int saved_otyp = (int)obj->otyp; /* for panic */ if (obj->where != OBJ_FREE) panic("addinv: obj not free"); @@ -411,12 +412,16 @@ struct obj *obj; extra to quivered stack is more useful than to wielded one */ if (uquiver && merged(&uquiver, &obj)) { obj = uquiver; + if (!obj) + panic("addinv: null obj after quiver merge otyp=%d", saved_otyp); goto added; } /* merge if possible; find end of chain in the process */ for (prev = 0, otmp = invent; otmp; prev = otmp, otmp = otmp->nobj) if (merged(&otmp, &obj)) { obj = otmp; + if (!obj) + panic("addinv: null obj after merge otyp=%d", saved_otyp); goto added; } /* didn't merge, so insert into chain */ diff --git a/src/options.c b/src/options.c index 7c0998917..fe83b2f1a 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 options.c $NHDT-Date: 1429953065 2015/04/25 09:11:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.186 $ */ +/* NetHack 3.5 options.c $NHDT-Date: 1430192504 2015/04/28 03:41:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.189 $ */ /* NetHack 3.5 options.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.153 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1279,7 +1279,6 @@ add_menu_coloring(str) char *str; { int i, c = NO_COLOR, a = ATR_NONE; - struct menucoloring *tmp; char *tmps, *cs = strchr(str, '='); if (!cs || !str) return FALSE;