Commit fff2bdc8 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/takdec: Free buffer on error pathes

Fixes: memleak
Fixes: 15446/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5662875831500800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent a7e02cf3
...@@ -146,7 +146,7 @@ static int tak_read_header(AVFormatContext *s) ...@@ -146,7 +146,7 @@ static int tak_read_header(AVFormatContext *s)
ret = avpriv_tak_parse_streaminfo(&ti, buffer, size -3); ret = avpriv_tak_parse_streaminfo(&ti, buffer, size -3);
if (ret < 0) if (ret < 0)
return AVERROR_INVALIDDATA; goto end;
if (ti.samples > 0) if (ti.samples > 0)
st->duration = ti.samples; st->duration = ti.samples;
st->codecpar->bits_per_coded_sample = ti.bps; st->codecpar->bits_per_coded_sample = ti.bps;
...@@ -160,8 +160,10 @@ static int tak_read_header(AVFormatContext *s) ...@@ -160,8 +160,10 @@ static int tak_read_header(AVFormatContext *s)
st->codecpar->extradata_size = size - 3; st->codecpar->extradata_size = size - 3;
buffer = NULL; buffer = NULL;
} else if (type == TAK_METADATA_LAST_FRAME) { } else if (type == TAK_METADATA_LAST_FRAME) {
if (size != 11) if (size != 11) {
return AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto end;
}
init_get_bits8(&gb, buffer, size - 3); init_get_bits8(&gb, buffer, size - 3);
tc->mlast_frame = 1; tc->mlast_frame = 1;
tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) + tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) +
...@@ -176,6 +178,9 @@ static int tak_read_header(AVFormatContext *s) ...@@ -176,6 +178,9 @@ static int tak_read_header(AVFormatContext *s)
} }
return AVERROR_EOF; return AVERROR_EOF;
end:
av_freep(&buffer);
return ret;
} }
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment