MediaMetadataRetriever: Fix null pointer exception

This CL fixes a null pointer exception by adding a null check.

Bug: 170357507
Test: run android.media.cts.ThumbnailUtilsTest and no crash
Change-Id: I60645e4382700993ff7e1bc992b970d89b5b600e
(cherry picked from commit fc24bd264ef1f599efa834fc120bc6d1ed304af3)
diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp
index 126897a..ddc51cd 100644
--- a/media/jni/android_media_MediaMetadataRetriever.cpp
+++ b/media/jni/android_media_MediaMetadataRetriever.cpp
@@ -464,11 +464,13 @@
                 || thumbPixels * 6 >= maxPixels) {
             frameMemory = retriever->getImageAtIndex(
                     index, colorFormat, false /*metaOnly*/, true /*thumbnail*/);
-            // TODO: Using unsecurePointer() has some associated security pitfalls
-            //       (see declaration for details).
-            //       Either document why it is safe in this case or address the
-            //       issue (e.g. by copying).
-            videoFrame = static_cast<VideoFrame *>(frameMemory->unsecurePointer());
+            if (frameMemory != 0) {
+                // TODO: Using unsecurePointer() has some associated security pitfalls
+                //       (see declaration for details).
+                //       Either document why it is safe in this case or address the
+                //       issue (e.g. by copying).
+                videoFrame = static_cast<VideoFrame *>(frameMemory->unsecurePointer());
+            }
 
             if (thumbPixels > maxPixels) {
                 int downscale = ceil(sqrt(thumbPixels / (float)maxPixels));