diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2013-06-12 14:27:00 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-06-16 15:56:50 +0200 |
commit | bbb2945f2dfbc2306c1655bf7eb6e220912a9a7c (patch) | |
tree | 0841f8d02531d1733f568ba219785eb83ba57f2e /libavcodec/smacker.c | |
parent | f52edef30197735bfb937e9e723ab1e7b31165c6 (diff) | |
download | ffmpeg-bbb2945f2dfbc2306c1655bf7eb6e220912a9a7c.tar.gz |
smacker: check the return value of smacker_decode_tree
Also prevent a memory leak.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/smacker.c')
-rw-r--r-- | libavcodec/smacker.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index ca9194f576..5f84c50ec8 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -629,7 +629,16 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, h[i].lengths = av_mallocz(256 * sizeof(int)); h[i].values = av_mallocz(256 * sizeof(int)); skip_bits1(&gb); - smacker_decode_tree(&gb, &h[i], 0, 0); + if (smacker_decode_tree(&gb, &h[i], 0, 0) < 0) { + for (; i >= 0; i--) { + if (vlc[i].table) + ff_free_vlc(&vlc[i]); + av_free(h[i].bits); + av_free(h[i].lengths); + av_free(h[i].values); + } + return AVERROR_INVALIDDATA; + } skip_bits1(&gb); if(h[i].current > 1) { res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length, |