Skip to content

Commit

Permalink
Missing dex array init detector
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcMil committed Oct 9, 2024
1 parent 2fb64a4 commit 9301f8b
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions src/main/java/soot/toDex/DexArrayInitDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
import soot.Value;
import soot.jimple.ArrayRef;
import soot.jimple.AssignStmt;
import soot.jimple.Constant;
import soot.jimple.DoubleConstant;
import soot.jimple.FloatConstant;
import soot.jimple.IntConstant;
import soot.jimple.LongConstant;
import soot.jimple.NewArrayExpr;

/**
Expand Down Expand Up @@ -92,28 +96,34 @@ public void constructArrayInitializations(Body body) {
} else {
arrayValues = null;
}
} else if (assignStmt.getLeftOp() instanceof ArrayRef && assignStmt.getRightOp() instanceof IntConstant
} else if (assignStmt.getLeftOp() instanceof ArrayRef && assignStmt.getRightOp() instanceof Constant
/*
* NumericConstant
*/
&& arrayValues != null) {
ArrayRef aref = (ArrayRef) assignStmt.getLeftOp();
if (aref.getBase() != concernedArray) {
arrayValues = null;
continue;
}
if (aref.getIndex() instanceof IntConstant) {
IntConstant intConst = (IntConstant) aref.getIndex();
if (intConst.value == arrayValues.size()) {
arrayValues.add(assignStmt.getRightOp());
if (intConst.value == 0) {
arrayInitStmt = u;
} else if (intConst.value == arraySize - 1) {
curIgnoreUnits.add(u);
checkAndSave(arrayInitStmt, arrayValues, arraySize, curIgnoreUnits);
arrayValues = null;
Value rop = assignStmt.getRightOp();
if (rop instanceof IntConstant || rop instanceof LongConstant || rop instanceof FloatConstant
|| rop instanceof DoubleConstant) {
ArrayRef aref = (ArrayRef) assignStmt.getLeftOp();
if (aref.getBase() != concernedArray) {
arrayValues = null;
continue;
}
if (aref.getIndex() instanceof IntConstant) {
IntConstant intConst = (IntConstant) aref.getIndex();
if (intConst.value == arrayValues.size()) {
arrayValues.add(rop);
if (intConst.value == 0) {
arrayInitStmt = u;
} else if (intConst.value == arraySize - 1) {
curIgnoreUnits.add(u);
checkAndSave(arrayInitStmt, arrayValues, arraySize, curIgnoreUnits);
arrayValues = null;
} else {
curIgnoreUnits.add(u);
}
} else {
curIgnoreUnits.add(u);
arrayValues = null;
}
} else {
arrayValues = null;
Expand Down

0 comments on commit 9301f8b

Please sign in to comment.