Merge "MediaMetadataRetriever: Fix null pointer exception"

This commit is contained in:
TreeHugger Robot
2020-12-12 02:14:45 +00:00
committed by Android (Google) Code Review

View File

@@ -464,11 +464,13 @@ static jobject android_media_MediaMetadataRetriever_getThumbnailImageAtIndex(
|| 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));