MediaPlayer: properly handle released surfaces
Bug: 5396571
Change-Id: I6af87cb04f09f9ae6ea77cd7ba31108a3e93d24a
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index f3174fe..63cbf5e 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -274,8 +274,14 @@
sp<ISurfaceTexture> new_st;
if (jsurface) {
sp<Surface> surface(Surface_getSurface(env, jsurface));
- new_st = surface->getSurfaceTexture();
- new_st->incStrong(thiz);
+ if (surface != NULL) {
+ new_st = surface->getSurfaceTexture();
+ new_st->incStrong(thiz);
+ } else {
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "The surface has been released");
+ return;
+ }
}
env->SetIntField(thiz, fields.surface_texture, (int)new_st.get());