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)
This commit is contained in:
parent
d69da8475e
commit
0dde01cad1
|
@ -898,7 +898,7 @@ static const char *tops(int index)
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return unknown;
|
return unknown;
|
||||||
}
|
}
|
||||||
if (index > OP_MAX) {
|
if (index >= OP_MAX) {
|
||||||
return unknown;
|
return unknown;
|
||||||
}
|
}
|
||||||
return table_ops[index].name;
|
return table_ops[index].name;
|
||||||
|
@ -10398,7 +10398,7 @@ static void simplify(struct compile_state *state, struct triple *ins)
|
||||||
do {
|
do {
|
||||||
op = ins->op;
|
op = ins->op;
|
||||||
do_simplify = 0;
|
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;
|
do_simplify = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue