1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/webpenc: Fix memleak when trailer is never written

When the trailer is never written (or when a stream switches from
non-animation mode to animation mode mid-stream), a cached packet
(if existing) would leak. Fix this by adding a deinit function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 3903c139a9)
This commit is contained in:
Andreas Rheinhardt 2021-03-18 23:27:57 +01:00 committed by Andreas Rheinhardt
parent ceb5863d04
commit a57ba45eb4

View File

@ -191,6 +191,13 @@ static int webp_write_trailer(AVFormatContext *s)
return 0;
}
static void webp_deinit(AVFormatContext *s)
{
WebpContext *w = s->priv_data;
av_packet_unref(&w->last_pkt);
}
#define OFFSET(x) offsetof(WebpContext, x)
#define ENC AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
@ -214,6 +221,7 @@ AVOutputFormat ff_webp_muxer = {
.write_header = webp_write_header,
.write_packet = webp_write_packet,
.write_trailer = webp_write_trailer,
.deinit = webp_deinit,
.priv_class = &webp_muxer_class,
.flags = AVFMT_VARIABLE_FPS,
};