static analyzer bit in uhitm.c
src/uhitm.c(1172): warning: Reading invalid data from 'mons'. Analyzer wasn't happy with the index into mons[] array only being validated by '!= -1'. Update the check for the index to include the full array index range, including ensuring that it is also '< NUMMONS'.
This commit is contained in:
+5
-4
@@ -1169,10 +1169,11 @@ hmon_hitmon_misc_obj(
|
|||||||
return;
|
return;
|
||||||
/*return (boolean) (!DEADMONSTER(mon));*/
|
/*return (boolean) (!DEADMONSTER(mon));*/
|
||||||
} else { /* ordinary egg(s) */
|
} else { /* ordinary egg(s) */
|
||||||
const char *eggp = (obj->corpsenm != NON_PM
|
enum monnums mnum = obj->corpsenm;
|
||||||
&& obj->known)
|
const char *eggp =
|
||||||
? the(mons[obj->corpsenm].pmnames[NEUTRAL])
|
(mnum >= LOW_PM && mnum < NUMMONS && obj->known)
|
||||||
: (cnt > 1L) ? "some" : "an";
|
? the(mons[mnum].pmnames[NEUTRAL])
|
||||||
|
: (cnt > 1L) ? "some" : "an";
|
||||||
|
|
||||||
You("hit %s with %s egg%s.", mon_nam(mon), eggp,
|
You("hit %s with %s egg%s.", mon_nam(mon), eggp,
|
||||||
plur(cnt));
|
plur(cnt));
|
||||||
|
|||||||
Reference in New Issue
Block a user