by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavformat/brstm.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/libavformat/brstm.c b/libavformat/brstm.c index ca965ed7e1..22d862ae43 100644 --- a/libavformat/brstm.c +++ b/libavformat/brstm.c @@ -92,7 +92,6 @@ static int read_header(AVFormatContext *s) int64_t h1offset, pos, toffset; uint32_t size, asize, start = 0; AVStream *st; - int ret = AVERROR_EOF; int loop = 0; int bfstm = !strcmp("bfstm", s->iformat->name); @@ -266,16 +265,14 @@ static int read_header(AVFormatContext *s) for (ch = 0; ch < st->codecpar->channels; ch++) { if (avio_read(s->pb, b->table + ch * 32, 32) != 32) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } avio_skip(s->pb, bfstm ? 14 : 24); } } if (size < (avio_tell(s->pb) - pos)) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } avio_skip(s->pb, size - (avio_tell(s->pb) - pos)); @@ -284,8 +281,7 @@ static int read_header(AVFormatContext *s) chunk = avio_rl32(s->pb); size = read32(s); if (size < 8) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } size -= 8; switch (chunk) { @@ -297,8 +293,7 @@ static int read_header(AVFormatContext *s) asize = b->block_count * st->codecpar->channels * 4; if (size < asize) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } if (b->adpc) { av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n"); @@ -306,8 +301,7 @@ static int read_header(AVFormatContext *s) } else { b->adpc = av_mallocz(asize); if (!b->adpc) { - ret = AVERROR(ENOMEM); - goto fail; + return AVERROR(ENOMEM); } if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) { // Big-endian BFSTMs have little-endian SEEK tables @@ -327,8 +321,7 @@ static int read_header(AVFormatContext *s) if ((start < avio_tell(s->pb)) || (!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE))) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } avio_skip(s->pb, start - avio_tell(s->pb)); @@ -349,10 +342,7 @@ skip: } } -fail: - read_close(s); - - return ret; + return AVERROR_EOF; } static int read_packet(AVFormatContext *s, AVPacket *pkt) @@ -467,6 +457,7 @@ AVInputFormat ff_brstm_demuxer = { .read_close = read_close, .read_seek = read_seek, .extensions = "brstm", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; AVInputFormat ff_bfstm_demuxer = { @@ -479,4 +470,5 @@ AVInputFormat ff_bfstm_demuxer = { .read_close = read_close, .read_seek = read_seek, .extensions = "bfstm,bcstm", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".