diff options
author | Marton Balint <cus@passwd.hu> | 2016-06-11 18:52:27 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2016-06-13 22:43:22 +0200 |
commit | 301ead131381d83e9ff0167b9094b04bde156f79 (patch) | |
tree | 363b71d34bf972ff601209e0319c6a8c58dfa0a6 /libavformat/mux.c | |
parent | 4bee44007a935adda805dfbb4494fc6502bd216a (diff) |
avformat/mux: call deinit if write_header fails
Docs clearly states that av_write_trailer should only be called if
avformat_write_header was successful, therefore we have to deinit if we return
failure.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r-- | libavformat/mux.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index 91388e3790..bef230f8eb 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -485,14 +485,14 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) if (ret >= 0 && s->pb && s->pb->error < 0) ret = s->pb->error; if (ret < 0) - return ret; + goto fail; if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS) avio_flush(s->pb); s->internal->header_written = 1; } if ((ret = init_pts(s)) < 0) - return ret; + goto fail; if (s->avoid_negative_ts < 0) { av_assert2(s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO); @@ -503,6 +503,11 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) } return 0; + +fail: + if (s->oformat->deinit) + s->oformat->deinit(s); + return ret; } #define AV_PKT_FLAG_UNCODED_FRAME 0x2000 |