From d5e4bc05c87b83d9c2f3802cd5525d94cac03e5d Mon Sep 17 00:00:00 2001 From: Jadon Fowler Date: Sat, 13 Jun 2020 01:18:11 -0400 Subject: [PATCH] Fix some NPEs The one involving inner classes appeared when it encountered an anonymous inner class. `blah.blah$1` made the outerName null. I have no idea what's up with the frame analysis, but skipping null frames let everything run fine. Signed-off-by: Jadon Fowler --- src/matcher/type/Analysis.java | 3 +++ src/matcher/type/ClassEnvironment.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/matcher/type/Analysis.java b/src/matcher/type/Analysis.java index f370d8eb..9c44395a 100644 --- a/src/matcher/type/Analysis.java +++ b/src/matcher/type/Analysis.java @@ -2008,6 +2008,9 @@ static void checkInitializer(FieldInstance field, ClassFeatureExtractor context) while ((in = positionsToTrace.poll()) != null) { int pos = il.indexOf(in); Frame frame = frames[pos]; + if (frame == null) { + continue; + } int stackConsumed = getStackDemand(in, frame); for (int i = 0; i < stackConsumed; i++) { diff --git a/src/matcher/type/ClassEnvironment.java b/src/matcher/type/ClassEnvironment.java index 13afb152..1eb45311 100644 --- a/src/matcher/type/ClassEnvironment.java +++ b/src/matcher/type/ClassEnvironment.java @@ -508,6 +508,9 @@ private static void detectOuterClass(ClassInstance cls, ClassNode cn) { } else { // determine outer class by outer$inner name pattern for (InnerClassNode icn : cn.innerClasses) { if (icn.name.equals(cn.name)) { + if (icn.outerName == null) { + return; + } addOuterClass(cls, icn.outerName, true); return; }