Skip to content

Commit

Permalink
Merge pull request #2136 from MarcMil/mdev
Browse files Browse the repository at this point in the history
Make sure that we do not have branch statements within array initializers
  • Loading branch information
StevenArzt authored Jan 12, 2025
2 parents 8cc7798 + 2d77662 commit 0c81657
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/soot/toDex/DexArrayInitDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
import soot.Value;
import soot.jimple.ArrayRef;
import soot.jimple.AssignStmt;
import soot.jimple.BranchableStmt;
import soot.jimple.Constant;
import soot.jimple.DoubleConstant;
import soot.jimple.FloatConstant;
import soot.jimple.IntConstant;
import soot.jimple.LongConstant;
import soot.jimple.NewArrayExpr;
import soot.jimple.Stmt;

/**
* Detector class that identifies array initializations and packs them into a single instruction:
Expand Down Expand Up @@ -76,6 +78,12 @@ public void constructArrayInitializations(Body body) {
Set<Unit> curIgnoreUnits = null;
int arraySize = 0;
Value concernedArray = null;
Set<Stmt> directGotoTargets = new HashSet<>();
for (Unit u : body.getUnits()) {
if (u instanceof BranchableStmt) {
directGotoTargets.add((Stmt) ((BranchableStmt) u).getTarget());
}
}
for (Unit u : body.getUnits()) {
if (!(u instanceof AssignStmt)) {
arrayValues = null;
Expand Down Expand Up @@ -105,7 +113,7 @@ public void constructArrayInitializations(Body body) {
if (rop instanceof IntConstant || rop instanceof LongConstant || rop instanceof FloatConstant
|| rop instanceof DoubleConstant) {
ArrayRef aref = (ArrayRef) assignStmt.getLeftOp();
if (aref.getBase() != concernedArray) {
if (aref.getBase() != concernedArray || directGotoTargets.contains(assignStmt)) {
arrayValues = null;
continue;
}
Expand Down

0 comments on commit 0c81657

Please sign in to comment.