diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-01-02 00:36:39 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-03-09 21:16:56 +0100 |
commit | c35e456f54d6c59ea62b18ce5b273da67c60903c (patch) | |
tree | d80b90cb731e331dec78afba738bedcf9665ca2d | |
parent | 1a549efefb590a83b2516dfd287dbda4e8d6b846 (diff) | |
download | ffmpeg-c35e456f54d6c59ea62b18ce5b273da67c60903c.tar.gz |
avformat/mvdec: Allocate extradata only once
Fixes: memleak
Fixes: 28686/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5822961932173312
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/mvdec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index f1f73e51f9..2aef93a735 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -213,10 +213,12 @@ static int parse_video_var(AVFormatContext *avctx, AVStream *st, st->codecpar->width = var_read_int(pb, size); } else if (!strcmp(name, "ORIENTATION")) { if (var_read_int(pb, size) == 1101) { - st->codecpar->extradata = av_strdup("BottomUp"); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); - st->codecpar->extradata_size = 9; + if (!st->codecpar->extradata) { + st->codecpar->extradata = av_strdup("BottomUp"); + if (!st->codecpar->extradata) + return AVERROR(ENOMEM); + st->codecpar->extradata_size = 9; + } } } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) { var_read_metadata(avctx, name, size); |