From 0dde01cad1c0b1422c845fc201733be559004fb7 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 11 Nov 2013 15:57:09 +0100 Subject: romcc: Fix off-by-one Arrays are indexed 0..(number_of_element-1). Change-Id: I2157e74340568636d588113d1d2d8cae50082da2 Found-by: Coverity Scan Signed-off-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/4089 Reviewed-by: Ronald G. Minnich Reviewed-by: Stefan Reinauer Tested-by: build bot (Jenkins) --- util/romcc/romcc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c index 0c7c7e1f8e..b045b468e4 100644 --- a/util/romcc/romcc.c +++ b/util/romcc/romcc.c @@ -898,7 +898,7 @@ static const char *tops(int index) if (index < 0) { return unknown; } - if (index > OP_MAX) { + if (index >= OP_MAX) { return unknown; } return table_ops[index].name; @@ -10398,7 +10398,7 @@ static void simplify(struct compile_state *state, struct triple *ins) do { op = ins->op; do_simplify = 0; - if ((op < 0) || (op > sizeof(table_simplify)/sizeof(table_simplify[0]))) { + if ((op < 0) || (op >= sizeof(table_simplify)/sizeof(table_simplify[0]))) { do_simplify = 0; } else { -- cgit v1.2.3