analysis lint for u*.c
One actual bug: mhitm_ad_ench() could pass Null to drain_item() which was not prepared to deal with that.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 u_init.c $NHDT-Date: 1725227809 2024/09/01 21:56:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.111 $ */
|
||||
/* NetHack 3.7 u_init.c $NHDT-Date: 1737620595 2025/01/23 00:23:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.113 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2017. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1329,6 +1329,7 @@ ini_inv(struct trobj *trop)
|
||||
* it was UNDEF_TYP or not after this. */
|
||||
|
||||
otyp = ini_inv_obj_substitution(trop, obj);
|
||||
nhUse(otyp);
|
||||
|
||||
/* nudist gets no armor */
|
||||
if (u.uroleplay.nudist && obj->oclass == ARMOR_CLASS) {
|
||||
|
||||
11
src/uhitm.c
11
src/uhitm.c
@@ -1813,8 +1813,10 @@ hmon_hitmon(
|
||||
|
||||
hmon_hitmon_msg_hit(&hmd, mon, obj);
|
||||
|
||||
if (hmd.dryit) /* dryit implies wet towel, so 'obj' is still intact */
|
||||
if (hmd.dryit) { /* dryit implies wet towel, so 'obj' is still intact */
|
||||
assert(obj != NULL);
|
||||
dry_a_towel(obj, -1, TRUE);
|
||||
}
|
||||
|
||||
if (hmd.silvermsg)
|
||||
hmon_hitmon_msg_silver(&hmd, mon, obj);
|
||||
@@ -1826,8 +1828,10 @@ hmon_hitmon(
|
||||
obj->opoisoned was cleared above and any message referring to
|
||||
"poisoned <obj>" has now been given; we want just "<obj>" for
|
||||
last message, so reformat while obj is still accessible */
|
||||
if (hmd.unpoisonmsg)
|
||||
if (hmd.unpoisonmsg) {
|
||||
assert(obj != NULL);
|
||||
Strcpy(hmd.saved_oname, cxname(obj));
|
||||
}
|
||||
|
||||
/* [note: thrown obj might go away during killed()/xkilled() call
|
||||
(via 'thrownobj'; if swallowed, it gets added to engulfer's
|
||||
@@ -3508,6 +3512,7 @@ mhitm_ad_slim(
|
||||
mhm->damage = 0;
|
||||
}
|
||||
}
|
||||
nhUse(pd);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3549,7 +3554,7 @@ mhitm_ad_ench(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (drain_item(obj, FALSE)) {
|
||||
if (obj && drain_item(obj, FALSE)) {
|
||||
pline("%s less effective.", Yobjnam2(obj, "seem"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user