summaryrefslogtreecommitdiff
path: root/libavformat/asfenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-05 22:46:23 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-10-03 20:50:50 +0200
commit87a4138d4b753c1ab41d0f8cb6891586adec471f (patch)
tree19f4b33f455443aee7e4f94bdeac43421a98d985 /libavformat/asfenc.c
parentea7a81bc1dfa0ecb0ed3ba35fbe0bcfd1d132804 (diff)
avformat/asfenc: Add deinit function
Fixes leaks when the trailer is never written. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/asfenc.c')
-rw-r--r--libavformat/asfenc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index e400b0a5b4..c9fc3a7b22 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -760,8 +760,6 @@ static int asf_write_header(AVFormatContext *s)
* data_size - asf->data_offset at the moment this function is done.
* It is needed to use asf as a streamable format. */
if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
- //av_free(asf);
- av_freep(&asf->index_ptr);
return -1;
}
@@ -1101,10 +1099,16 @@ static int asf_write_trailer(AVFormatContext *s)
asf_write_header1(s, file_size, data_size - asf->data_offset);
}
- av_freep(&asf->index_ptr);
return 0;
}
+static void asf_deinit(AVFormatContext *s)
+{
+ ASFContext *const asf = s->priv_data;
+
+ av_freep(&asf->index_ptr);
+}
+
static const AVOption asf_options[] = {
{ "packet_size", "Packet size", offsetof(ASFContext, packet_size), AV_OPT_TYPE_INT, {.i64 = 3200}, PACKET_SIZE_MIN, PACKET_SIZE_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
@@ -1132,6 +1136,7 @@ const AVOutputFormat ff_asf_muxer = {
.flags = AVFMT_GLOBALHEADER,
.codec_tag = asf_codec_tags,
.priv_class = &asf_muxer_class,
+ .deinit = asf_deinit,
};
#endif /* CONFIG_ASF_MUXER */
@@ -1150,5 +1155,6 @@ const AVOutputFormat ff_asf_stream_muxer = {
.flags = AVFMT_GLOBALHEADER,
.codec_tag = asf_codec_tags,
.priv_class = &asf_muxer_class,
+ .deinit = asf_deinit,
};
#endif /* CONFIG_ASF_STREAM_MUXER */