Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-04-14 05:30:59 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-20 03:03:53 +0300
commitf60a1e8d34061ee2e692bb5d5d69d4b71a216aa4 (patch)
treedc19d7dab7ae84a251f387561daa5b9627c09b5a /libavformat/oggenc.c
parentdf88108c973d3844a1ae95d3bf8064f59926bc09 (diff)
avformat/oggenc: Don't free AVStream's priv_data, fix memleak
For FLAC, Speex, Opus and VP8 the Ogg muxer allocates two buffers for building the headers: The first for extradata in an Ogg-specific format and the second contains a Vorbiscomment. These buffers are reachable via pointers in the corresponding AVStream's priv_data. If an error happens during building the headers, the AVStream's priv_data would be freed. This is pointless in general as it would be freed generically anyway, but here it is actively harmful: If the second of the aforementioned allocations fails, the first buffer would leak upon freeing priv_data. This commit stops freeing priv_data manually, which allows the muxer to properly clean up in the deinit function. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 0fcf74f4357e949f5971d39b04a128103b8949bb)
Diffstat (limited to 'libavformat/oggenc.c')
-rw-r--r--libavformat/oggenc.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 06021c4f4b..dea390b015 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -547,7 +547,6 @@ static int ogg_init(AVFormatContext *s)
&st->metadata);
if (err) {
av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
- av_freep(&st->priv_data);
return err;
}
} else if (st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {
@@ -556,7 +555,6 @@ static int ogg_init(AVFormatContext *s)
&st->metadata);
if (err) {
av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
- av_freep(&st->priv_data);
return err;
}
} else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
@@ -565,7 +563,6 @@ static int ogg_init(AVFormatContext *s)
&st->metadata, s->chapters, s->nb_chapters);
if (err) {
av_log(s, AV_LOG_ERROR, "Error writing Opus headers\n");
- av_freep(&st->priv_data);
return err;
}
} else if (st->codecpar->codec_id == AV_CODEC_ID_VP8) {
@@ -573,7 +570,6 @@ static int ogg_init(AVFormatContext *s)
s->flags & AVFMT_FLAG_BITEXACT);
if (err) {
av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n");
- av_freep(&st->priv_data);
return err;
}
} else {
@@ -586,7 +582,7 @@ static int ogg_init(AVFormatContext *s)
st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
(const uint8_t**)oggstream->header, oggstream->header_len) < 0) {
av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
- av_freep(&st->priv_data);
+ oggstream->header[1] = NULL;
return AVERROR_INVALIDDATA;
}
@@ -754,7 +750,6 @@ static void ogg_free(AVFormatContext *s)
av_freep(&oggstream->header[0]);
}
av_freep(&oggstream->header[1]);
- av_freep(&st->priv_data);
}
}