From ac87656855947c1b3fc021b1051ab0e79fcc2fb9 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 12 Jan 2023 16:28:39 -0500 Subject: [PATCH] remove a static analyzer warning from botl.c One static analyzer warned that there was a lower bound range check ahead of the array index, but no upper bound check. --- src/botl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/botl.c b/src/botl.c index 243490018..ab37145ad 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1217,8 +1217,9 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx) || (fld == BL_HP && iflags.wc2_hitpointbar)) { fldmax = curr->idxmax; pc = (fldmax == BL_EXP) ? exp_percentage() - : (fldmax >= 0) ? percentage(curr, &gb.blstats[idx][fldmax]) - : 0; /* bullet proofing; can't get here */ + : (fldmax >= 0 && fldmax < MAXBLSTATS) + ? percentage(curr, &gb.blstats[idx][fldmax]) + : 0; /* bullet proofing; can't get here */ if (pc != prev->percent_value) chg = 1; curr->percent_value = pc;