Skip to content

Commit c7d9c23

Browse files
DoHuberGSOberon Swings
authored andcommitted
Add null check for classNode.anns to avoid possible NPE
Summary: In an app that recently crashed appsweep, it happens that one class (`ve5`) has a dex annotation wherein it declares that another class (`ue5`) is a member class. This makes Dex2Pro set `ve5` as the enclosing class of `ue5`. Later, when it tries to parse annotations for `ue5`, it assumes that the annotations are not `null`, as it is an inner class and as such is expected (but apparently not required by the specification) to have the according annotations. However, `ue5` does not declare any annotations, which in turn causes the null pointer. This diff introduces a null check that avoids the `NullPointerException`. With the null check, Dex2Pro would remove ue5 from the list of ve5 's inner classes, which seems like sensible behavior to me.
1 parent 36673d7 commit c7d9c23

File tree

1 file changed

+1
-1
lines changed
  • android/src/main/java/proguard/dexfile/converter

1 file changed

+1
-1
lines changed

android/src/main/java/proguard/dexfile/converter/Dex2Pro.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ private void convertClass(int dexVersion, DexClassNode classNode, ClassVisitor c
530530
if (clzInfo != null) {
531531
// isInnerClass = clzInfo.enclosingClass != null || clzInfo.enclosingMethod != null;
532532
if (clzInfo.enclosingClass != null || clzInfo.enclosingMethod != null) {
533-
if (classNode.anns.stream().noneMatch(x ->
533+
if (classNode.anns != null && classNode.anns.stream().noneMatch(x ->
534534
x.type.equals("Ldalvik/annotation/EnclosingMethod;"))) {
535535
isInnerClass = true;
536536
} else if (clzInfo.enclosingClass != null) {

0 commit comments

Comments
 (0)