avformat/icoenc: Add deinit function

Prevents memleaks in situations where the trailer isn't written, e.g.
because of errors during writing the header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Andreas Rheinhardt 2019-10-23 14:59:44 +02:00 committed by Michael Niedermayer
parent f53525d248
commit 3d5d0301c3
1 changed files with 8 additions and 2 deletions

View File

@ -183,11 +183,16 @@ static int ico_write_trailer(AVFormatContext *s)
avio_wl32(pb, ico->images[i].offset); avio_wl32(pb, ico->images[i].offset);
} }
av_freep(&ico->images);
return 0; return 0;
} }
static void ico_deinit(AVFormatContext *s)
{
IcoMuxContext *ico = s->priv_data;
av_freep(&ico->images);
}
AVOutputFormat ff_ico_muxer = { AVOutputFormat ff_ico_muxer = {
.name = "ico", .name = "ico",
.long_name = NULL_IF_CONFIG_SMALL("Microsoft Windows ICO"), .long_name = NULL_IF_CONFIG_SMALL("Microsoft Windows ICO"),
@ -199,5 +204,6 @@ AVOutputFormat ff_ico_muxer = {
.write_header = ico_write_header, .write_header = ico_write_header,
.write_packet = ico_write_packet, .write_packet = ico_write_packet,
.write_trailer = ico_write_trailer, .write_trailer = ico_write_trailer,
.deinit = ico_deinit,
.flags = AVFMT_NOTIMESTAMPS, .flags = AVFMT_NOTIMESTAMPS,
}; };