lavf/matroskaenc.c: Free dyn bufs in mkv_free. Fixes memory leaks when muxing fails.
authorSasi Inguva <isasi-at-google.com@ffmpeg.org>
Thu, 26 Jan 2017 19:26:46 +0000 (11:26 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 27 Jan 2017 21:16:37 +0000 (22:16 +0100)
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/matroskaenc.c

index f731b67..88f6c64 100644 (file)
@@ -393,6 +393,23 @@ static void put_xiph_size(AVIOContext *pb, int size)
  * Free the members allocated in the mux context.
  */
 static void mkv_free(MatroskaMuxContext *mkv) {
+    uint8_t* buf;
+    if (mkv->dyn_bc) {
+        avio_close_dyn_buf(mkv->dyn_bc, &buf);
+        av_free(buf);
+    }
+    if (mkv->info_bc) {
+        avio_close_dyn_buf(mkv->info_bc, &buf);
+        av_free(buf);
+    }
+    if (mkv->tracks_bc) {
+        avio_close_dyn_buf(mkv->tracks_bc, &buf);
+        av_free(buf);
+    }
+    if (mkv->tags_bc) {
+        avio_close_dyn_buf(mkv->tags_bc, &buf);
+        av_free(buf);
+    }
     if (mkv->main_seekhead) {
         av_freep(&mkv->main_seekhead->entries);
         av_freep(&mkv->main_seekhead);