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