Skip to content

Commit 5c06b0a

Browse files
committed
Fix for non-existing context wrapper class
1 parent a6d6913 commit 5c06b0a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/entryPointCreators/AndroidEntryPointCreator.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,14 @@ protected SootMethod createDummyMainInternal() {
293293
localVarsForClasses.put(applicationClass, applicationLocal);
294294
}
295295

296-
body.getUnits()
297-
.add(j.newInvokeStmt(j.newVirtualInvokeExpr(applicationLocal,
298-
Scene.v().makeMethodRef(
299-
Scene.v().getSootClassUnsafe(AndroidEntryPointConstants.CONTEXT_WRAPPER),
300-
AndroidEntryPointConstants.ATTACH_BASE_CONTEXT, false))));
296+
SootClass cw = Scene.v().getSootClassUnsafe(AndroidEntryPointConstants.CONTEXT_WRAPPER);
297+
if (cw == null) {
298+
//use application local type as a fallback, since this class also implements context wrapper
299+
cw = ((RefType) applicationLocal.getType()).getSootClass();
300+
}
301+
if (cw != null)
302+
body.getUnits().add(j.newInvokeStmt(j.newVirtualInvokeExpr(applicationLocal,
303+
Scene.v().makeMethodRef(cw, AndroidEntryPointConstants.ATTACH_BASE_CONTEXT, false))));
301304

302305
Map<SootClass, ContentProviderEntryPointCreator> cpComponents = new HashMap<>();
303306
// For some weird reason unknown to anyone except the flying spaghetti

soot-infoflow-android/src/soot/jimple/infoflow/android/entryPointCreators/components/ActivityEntryPointCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected void generateComponentLifecycle() {
9696
}
9797

9898
// 1. attachBaseContext
99-
searchAndBuildMethod(AndroidEntryPointConstants.ATTACH_BASE_CONTEXT, applicationLocal);
99+
searchAndBuildMethod(AndroidEntryPointConstants.ATTACH_BASE_CONTEXT, thisLocal);
100100

101101
// 2. onCreate:
102102
{

0 commit comments

Comments
 (0)