Skip to content

Commit

Permalink
Do not insert anything before the super() call in constructors, verif…
Browse files Browse the repository at this point in the history
…ier will reject anything accessing this reference there
  • Loading branch information
palant committed Mar 2, 2021
1 parent dae9006 commit 77be944
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/info/palant/apkInstrumentation/UnitSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import soot.jimple.Jimple;
import soot.jimple.JimpleBody;
import soot.jimple.NullConstant;
import soot.jimple.Stmt;
import soot.jimple.StringConstant;

public class UnitSequence extends ArrayList<Unit>
Expand Down Expand Up @@ -295,7 +296,14 @@ public Local getIdentity(Value obj)

public void insertBefore()
{
this.insertBefore(((JimpleBody)this.body).getFirstNonIdentityStmt());
Stmt unit = ((JimpleBody)this.body).getFirstNonIdentityStmt();
if (this.body.getMethod().getName().equals("<init>") && unit.containsInvokeExpr() && unit.getInvokeExpr().getMethod().getName().equals("<init>"))
{
// This is a super() constructor call, don't insert before it.
this.insertAfter(unit);
}
else
this.insertBefore(unit);
}

public void insertBefore(Unit unit)
Expand Down

0 comments on commit 77be944

Please sign in to comment.