提交 26aa0499 编写于 作者: A Andreas Rheinhardt 提交者: James Almer

avformat/apngenc: Add deinit function

Prevents memleaks when the trailer is never written (e.g. when there was
a write error when writing the header).

Fixes ticket #8347.
Signed-off-by: NAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: NJames Almer <jamrial@gmail.com>
上级 89389b7e
......@@ -251,7 +251,6 @@ static int apng_write_trailer(AVFormatContext *format_context)
if (apng->prev_packet) {
ret = flush_packet(format_context, NULL);
av_freep(&apng->prev_packet);
if (ret < 0)
return ret;
}
......@@ -266,12 +265,18 @@ static int apng_write_trailer(AVFormatContext *format_context)
apng_write_chunk(io_context, MKBETAG('a', 'c', 'T', 'L'), buf, 8);
}
av_freep(&apng->extra_data);
apng->extra_data = 0;
return 0;
}
static void apng_deinit(AVFormatContext *s)
{
APNGMuxContext *apng = s->priv_data;
av_packet_free(&apng->prev_packet);
av_freep(&apng->extra_data);
apng->extra_data_size = 0;
}
#define OFFSET(x) offsetof(APNGMuxContext, x)
#define ENC AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
......@@ -300,6 +305,7 @@ AVOutputFormat ff_apng_muxer = {
.write_header = apng_write_header,
.write_packet = apng_write_packet,
.write_trailer = apng_write_trailer,
.deinit = apng_deinit,
.priv_class = &apng_muxer_class,
.flags = AVFMT_VARIABLE_FPS,
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册