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
This commit is contained in:
nhmall
2015-04-27 23:42:06 -04:00
parent 86dc5cf588
commit 3924b01e73
2 changed files with 6 additions and 2 deletions

View File

@@ -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 */

View File

@@ -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;