lavf/matroskaenc.c: Free dyn bufs in mkv_free. Fixes memory leaks when muxing fails.

Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Sasi Inguva 2017-01-26 11:26:46 -08:00 committed by Michael Niedermayer
parent d1df72a702
commit e4a1d87ef8
1 changed files with 17 additions and 0 deletions

View 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);