Fix NPE in presence of uninitialized-new frame types
Bug: b/377531210
Change-Id: I3e09133ea48de97408838132d0c7d341ae40f9b6
diff --git a/src/main/java/com/android/tools/r8/cf/code/CfFrame.java b/src/main/java/com/android/tools/r8/cf/code/CfFrame.java
index 62a8f65..0dedc1d 100644
--- a/src/main/java/com/android/tools/r8/cf/code/CfFrame.java
+++ b/src/main/java/com/android/tools/r8/cf/code/CfFrame.java
@@ -9,6 +9,7 @@
import com.android.tools.r8.cf.code.frame.FrameType;
import com.android.tools.r8.cf.code.frame.PreciseFrameType;
import com.android.tools.r8.cf.code.frame.UninitializedFrameType;
+import com.android.tools.r8.cf.code.frame.UninitializedNew;
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.CfCompareHelper;
import com.android.tools.r8.graph.DexClassAndMethod;
@@ -281,7 +282,10 @@
registry.registerTypeReference(
frameType.asInitializedNonNullReferenceTypeWithoutInterfaces().getInitializedType());
} else if (frameType.isUninitializedNew()) {
- registry.registerTypeReference(frameType.asUninitializedNew().getUninitializedNewType());
+ UninitializedNew uninitializedNew = frameType.asUninitializedNew();
+ if (uninitializedNew.getUninitializedNewType() != null) {
+ registry.registerTypeReference(uninitializedNew.getUninitializedNewType());
+ }
}
}