Guard against native crash due to null Surface
Bug: 77874529
Test: record video, mini CTS
Change-Id: I00815fa334a9701e344b263e62549655299013cf
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index 000317e..16f6284 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -1261,6 +1261,11 @@
sp<PersistentSurface> persistentSurface =
android_media_MediaCodec_getPersistentInputSurface(env, object);
+ if (persistentSurface == NULL) {
+ throwExceptionAsNecessary(
+ env, BAD_VALUE, ACTION_CODE_FATAL, "input surface not valid");
+ return;
+ }
status_t err = codec->setInputSurface(persistentSurface);
if (err != NO_ERROR) {
throwExceptionAsNecessary(env, err);