diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-23 18:09:58 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-21 16:42:32 +0100 |
commit | fedbba5ea051a8d3f15907d4ffe10eb24da8b47b (patch) | |
tree | e985b6af23d322263afc4610ae79caa578aed243 /libavformat/rmdec.c | |
parent | d35916f6ea4964410073797d9ef73c1410d12b81 (diff) | |
download | ffmpeg-fedbba5ea051a8d3f15907d4ffe10eb24da8b47b.tar.gz |
avformat/rmdec: move packet allocation down
Fixes memleak
Fixes: msan_uninit-mem_7fc5d73327d4_6192_kuerti.ra
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 165f96cd2d687122748f862a0bc6e9908fe3d5d2)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rmdec.c')
-rw-r--r-- | libavformat/rmdec.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index baf3f0706c..73c9d0d042 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -257,16 +257,6 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, default: av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name)); } - if (ast->deint_id == DEINT_ID_INT4 || - ast->deint_id == DEINT_ID_GENR || - ast->deint_id == DEINT_ID_SIPR) { - if (st->codec->block_align <= 0 || - ast->audio_framesize * sub_packet_h > (unsigned)INT_MAX || - ast->audio_framesize * sub_packet_h < st->codec->block_align) - return AVERROR_INVALIDDATA; - if (av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h) < 0) - return AVERROR(ENOMEM); - } switch (ast->deint_id) { case DEINT_ID_INT4: if (ast->coded_framesize > ast->audio_framesize || @@ -288,6 +278,16 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, av_log(s, AV_LOG_ERROR, "Unknown interleaver %X\n", ast->deint_id); return AVERROR_INVALIDDATA; } + if (ast->deint_id == DEINT_ID_INT4 || + ast->deint_id == DEINT_ID_GENR || + ast->deint_id == DEINT_ID_SIPR) { + if (st->codec->block_align <= 0 || + ast->audio_framesize * sub_packet_h > (unsigned)INT_MAX || + ast->audio_framesize * sub_packet_h < st->codec->block_align) + return AVERROR_INVALIDDATA; + if (av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h) < 0) + return AVERROR(ENOMEM); + } if (read_all) { avio_r8(pb); |