Skip to content

Commit 0c81657

Browse files
authored
Merge pull request #2136 from MarcMil/mdev
Make sure that we do not have branch statements within array initializers
2 parents 8cc7798 + 2d77662 commit 0c81657

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/soot/toDex/DexArrayInitDetector.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636
import soot.Value;
3737
import soot.jimple.ArrayRef;
3838
import soot.jimple.AssignStmt;
39+
import soot.jimple.BranchableStmt;
3940
import soot.jimple.Constant;
4041
import soot.jimple.DoubleConstant;
4142
import soot.jimple.FloatConstant;
4243
import soot.jimple.IntConstant;
4344
import soot.jimple.LongConstant;
4445
import soot.jimple.NewArrayExpr;
46+
import soot.jimple.Stmt;
4547

4648
/**
4749
* Detector class that identifies array initializations and packs them into a single instruction:
@@ -76,6 +78,12 @@ public void constructArrayInitializations(Body body) {
7678
Set<Unit> curIgnoreUnits = null;
7779
int arraySize = 0;
7880
Value concernedArray = null;
81+
Set<Stmt> directGotoTargets = new HashSet<>();
82+
for (Unit u : body.getUnits()) {
83+
if (u instanceof BranchableStmt) {
84+
directGotoTargets.add((Stmt) ((BranchableStmt) u).getTarget());
85+
}
86+
}
7987
for (Unit u : body.getUnits()) {
8088
if (!(u instanceof AssignStmt)) {
8189
arrayValues = null;
@@ -105,7 +113,7 @@ public void constructArrayInitializations(Body body) {
105113
if (rop instanceof IntConstant || rop instanceof LongConstant || rop instanceof FloatConstant
106114
|| rop instanceof DoubleConstant) {
107115
ArrayRef aref = (ArrayRef) assignStmt.getLeftOp();
108-
if (aref.getBase() != concernedArray) {
116+
if (aref.getBase() != concernedArray || directGotoTargets.contains(assignStmt)) {
109117
arrayValues = null;
110118
continue;
111119
}

0 commit comments

Comments
 (0)