Fix out-of-bounds memory access
Valgrind flagged a pair of out-of-bounds memory accesses. Reorder
the compound statement to correct.
Thanks Valgrind!
Change-Id: I9cd9c4287640f5b4eaade76f921bf9fd33b07075
diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc
index d5f6720..afbefff 100644
--- a/src/compiler/codegen/RallocUtil.cc
+++ b/src/compiler/codegen/RallocUtil.cc
@@ -1169,7 +1169,7 @@
if (!(cUnit->disableOpt & (1 << kPromoteRegs))) {
// Promote fpRegs
- for (int i = 0; (fpRegs[i].count > 0) && (i < numRegs); i++) {
+ for (int i = 0; (i < numRegs) && (fpRegs[i].count > 0); i++) {
DCHECK(validSreg(cUnit,fpRegs[i].sReg));
if (cUnit->promotionMap[fpRegs[i].sReg].fpLocation != kLocPhysReg) {
int reg = oatAllocPreservedFPReg(cUnit, fpRegs[i].sReg,
@@ -1181,7 +1181,7 @@
}
// Promote core regs
- for (int i = 0; (coreRegs[i].count > 0) && i < numRegs; i++) {
+ for (int i = 0; (i < numRegs) && (coreRegs[i].count > 0); i++) {
DCHECK(validSreg(cUnit,coreRegs[i].sReg));
if (cUnit->promotionMap[coreRegs[i].sReg].coreLocation !=
kLocPhysReg) {