From 4256c970ad90bc555eccfd585048669bb69bca1c Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Fri, 15 Nov 2013 13:49:58 -0800 Subject: Fix metadata access Metadata string pointers become invalid after setting more metadata, so don't cache them. b/11692062 Change-Id: Iaf1afb24cf53f7fa36f49ce759355693494076e5 --- media/libstagefright/MPEG4Extractor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'media/libstagefright/MPEG4Extractor.cpp') diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index b8988e6..1ba1c6e 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1368,9 +1368,6 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return err; } - const char *mime; - CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); - if (max_size != 0) { // Assume that a given buffer only contains at most 10 chunks, // each chunk originally prefixed with a 2 byte length will @@ -1387,6 +1384,8 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { height = 1080; } + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) { // AVC requires compression ratio of at least 2, and uses // macroblocks @@ -1400,6 +1399,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } *offset += chunk_size; + // NOTE: setting another piece of metadata invalidates any pointers (such as the + // mimetype) previously obtained, so don't cache them. + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); // Calculate average frame rate. if (!strncasecmp("video/", mime, 6)) { size_t nSamples = mLastTrack->sampleTable->countSamples(); -- cgit v1.1