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

Commit 68b5a37d authored by Guang Qiao's avatar Guang Qiao Committed by Ray Essick
Browse files

MPEG4Writer:Fix MetaData use-after-free issue

MediaCodecSource's mMeta would be replaced if encoder posts
OUTPUT_FORMAT_CHANGED message.  MPEG4Writer needs to hold
the old mMeta to use its variables.

Bug: 144537993
Test: run cts -m CtsMediaTestCases -t android.media.cts.MediaRecorderTest
Change-Id: I52345a35fb8472bd58165e9060297f8d13f3b6fc
parent 733c7287
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -614,7 +614,8 @@ status_t MPEG4Writer::addSource(const sp<MediaSource> &source) {
    CHECK(source.get() != NULL);

    const char *mime;
    source->getFormat()->findCString(kKeyMIMEType, &mime);
    sp<MetaData> meta = source->getFormat();
    meta->findCString(kKeyMIMEType, &mime);

    if (Track::getFourCCForMime(mime) == NULL) {
        ALOGE("Unsupported mime '%s'", mime);