From c847a4835b2233d28f6479deeed0592d267ee7bd Mon Sep 17 00:00:00 2001 From: "wang, biao" Date: Tue, 30 Oct 2012 15:35:01 +0800 Subject: MetadataRetriever: Check null pointer to avoid tombstone crash. When the app's vm-heap is not enough, memory allocation for big object like bitmap may failed. This patch add protection for bitmap creating to avoid segment fault error in the following GetIntField function. Change-Id: I63977dc602f4ed395afd11004a0ed027173fb685 Signed-off-by: wang, biao Signed-off-by: TingX Li Signed-off-by: Wang LiangX --- media/jni/android_media_MediaMetadataRetriever.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index 6176f0f1f2b1..c2694f1fb9cb 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -262,6 +262,13 @@ static jobject android_media_MediaMetadataRetriever_getFrameAtTime(JNIEnv *env, width, height, config); + if (jBitmap == NULL) { + if (env->ExceptionCheck()) { + env->ExceptionClear(); + } + ALOGE("getFrameAtTime: create Bitmap failed!"); + return NULL; + } SkBitmap *bitmap = (SkBitmap *) env->GetLongField(jBitmap, fields.nativeBitmap); -- cgit v1.2.3-59-g8ed1b