fix crash due to no output format available -- DO NOT MERGE
Output format should arrive before we get first frame, but if
it doesn't, better fail it than crash.
bug: 69924594
bug: 75978033
Change-Id: I057ba49c8f83b9a301d409510717039ad894c391
(cherry picked from commit 6cb243cd2bb4d2fb41d12394fe5731ba098fc2ef)
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index ccce170..e8c3dd3 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -494,13 +494,18 @@
ALOGV("Timed-out waiting for output.. retries left = %zu", retriesLeft);
err = OK;
} else if (err == OK) {
+ if (outputFormat == NULL) {
+ decoder->releaseOutputBuffer(index);
+ err = ERROR_MALFORMED;
+ break;
+ }
+
// If we're seeking with CLOSEST option and obtained a valid targetTimeUs
// from the extractor, decode to the specified frame. Otherwise we're done.
ALOGV("Received an output buffer, timeUs=%lld", (long long)timeUs);
sp<MediaCodecBuffer> videoFrameBuffer = outputBuffers.itemAt(index);
int32_t width, height;
- CHECK(outputFormat != NULL);
CHECK(outputFormat->findInt32("width", &width));
CHECK(outputFormat->findInt32("height", &height));