Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a77c8dff authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Chih-yu Huang
Browse files

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)
parent 55afae1f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -464,11 +464,13 @@ static jobject android_media_MediaMetadataRetriever_getThumbnailImageAtIndex(
                || thumbPixels * 6 >= maxPixels) {
            frameMemory = retriever->getImageAtIndex(
                    index, colorFormat, false /*metaOnly*/, true /*thumbnail*/);
            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));