From 98dc5d7692591b7e9d4e576407f138f80c0a1e64 Mon Sep 17 00:00:00 2001 From: buzbee Date: Fri, 16 Mar 2012 19:12:11 -0700 Subject: 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 --- src/compiler/codegen/RallocUtil.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/compiler/codegen/RallocUtil.cc') diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc index d5f6720071..afbefff437 100644 --- a/src/compiler/codegen/RallocUtil.cc +++ b/src/compiler/codegen/RallocUtil.cc @@ -1169,7 +1169,7 @@ extern void oatDoPromotion(CompilationUnit* cUnit) 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 @@ extern void oatDoPromotion(CompilationUnit* cUnit) } // 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) { -- cgit v1.2.3-59-g8ed1b