From c3e4d0cf3f1fd24164e0a58db23b86b56c6dc7c8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 8 Sep 2013 12:46:20 +0200 Subject: Fixes based on problems from a static checker. --- cint_array.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cint_array.c') diff --git a/cint_array.c b/cint_array.c index 1d34c2f7..3945e6e7 100644 --- a/cint_array.c +++ b/cint_array.c @@ -150,10 +150,14 @@ cint_array_init(NODE *symbol ATTRIBUTE_UNUSED, NODE *subs ATTRIBUTE_UNUSED) { if (symbol == NULL) { long newval; + size_t nelems = (sizeof(power_two_table) / sizeof(power_two_table[0])); /* check relevant environment variables */ if ((newval = getenv_long("NHAT")) > 1 && newval < INT32_BIT) NHAT = newval; + /* don't allow overflow off the end of the table */ + if (NHAT >= nelems) + NHAT = nelems - 2; THRESHOLD = power_two_table[NHAT + 1]; } else null_array(symbol); -- cgit v1.2.3