Commit d624fb5d authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

avformat/webm_chunk: Add deinit function

This fixes memleaks if an error happens after one of the allocations
in init; or if the trailer isn't written (e.g. because there was an
error when writing a packet).
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent 42b00042
...@@ -258,13 +258,22 @@ static int webm_chunk_write_trailer(AVFormatContext *s) ...@@ -258,13 +258,22 @@ static int webm_chunk_write_trailer(AVFormatContext *s)
if (!oc->pb) { if (!oc->pb) {
ret = chunk_start(s); ret = chunk_start(s);
if (ret < 0) if (ret < 0)
goto fail; return ret;
} }
av_write_trailer(oc); av_write_trailer(oc);
ret = chunk_end(s, 0); return chunk_end(s, 0);
fail: }
avformat_free_context(oc);
return ret; static void webm_chunk_deinit(AVFormatContext *s)
{
WebMChunkContext *wc = s->priv_data;
if (!wc->avf)
return;
ffio_free_dyn_buf(&wc->avf->pb);
avformat_free_context(wc->avf);
wc->avf = NULL;
} }
#define OFFSET(x) offsetof(WebMChunkContext, x) #define OFFSET(x) offsetof(WebMChunkContext, x)
...@@ -296,6 +305,7 @@ AVOutputFormat ff_webm_chunk_muxer = { ...@@ -296,6 +305,7 @@ AVOutputFormat ff_webm_chunk_muxer = {
.write_header = webm_chunk_write_header, .write_header = webm_chunk_write_header,
.write_packet = webm_chunk_write_packet, .write_packet = webm_chunk_write_packet,
.write_trailer = webm_chunk_write_trailer, .write_trailer = webm_chunk_write_trailer,
.deinit = webm_chunk_deinit,
.priv_class = &webm_chunk_class, .priv_class = &webm_chunk_class,
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment