aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-10-20 22:56:13 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-02-02 14:18:21 +0100
commit0a0976cf825f0df282a3fa5941290daf60b45b1d (patch)
tree43f01f56e79f012feaed5e1852ca610a19f99705
parent5872cf02ab45974f5effc968a4405a05270c4e8f (diff)
downloadffmpeg-0a0976cf825f0df282a3fa5941290daf60b45b1d.tar.gz
avformat/ffmetadec: finalize AVBPrint on errors
Fixes: memleak Fixes: 26450/clusterfuzz-testcase-minimized-ffmpeg_dem_FFMETADATA_fuzzer-6249850443923456 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit a9271286171e069daea4726274a36a94e3f77d03) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/ffmetadec.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c
index 45c92f1ff6..6a30b58c41 100644
--- a/libavformat/ffmetadec.c
+++ b/libavformat/ffmetadec.c
@@ -182,7 +182,7 @@ static int read_header(AVFormatContext *s)
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
- return AVERROR(ENOMEM);
+ goto nomem;
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_FFMETADATA;
@@ -192,7 +192,7 @@ static int read_header(AVFormatContext *s)
AVChapter *ch = read_chapter(s);
if (!ch)
- return AVERROR(ENOMEM);
+ goto nomem;
m = &ch->metadata;
} else
@@ -208,6 +208,10 @@ static int read_header(AVFormatContext *s)
AV_TIME_BASE_Q);
return 0;
+nomem:
+ av_bprint_finalize(&bp, NULL);
+
+ return AVERROR(ENOMEM);
}
static int read_packet(AVFormatContext *s, AVPacket *pkt)