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
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index f130c9b..128ce8b 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -614,7 +614,8 @@
     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);