summaryrefslogtreecommitdiff
path: root/util/romcc
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2013-11-11 15:57:09 +0100
committerPatrick Georgi <patrick@georgi-clan.de>2013-11-16 09:49:35 +0100
commit0dde01cad1c0b1422c845fc201733be559004fb7 (patch)
treee4c316bb50c5f6baa7b99d09f1c79190338592ad /util/romcc
parentd69da8475e9794cfd8580457c63dafb8f5d240ed (diff)
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 <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/4089 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins)
Diffstat (limited to 'util/romcc')
-rw-r--r--util/romcc/romcc.c4
1 files changed, 2 insertions, 2 deletions
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 {