truemotion2: error out if the huffman tree has no nodes.
authorRonald S. Bultje <rsbultje@gmail.com>
Wed, 22 Feb 2012 20:19:52 +0000 (12:19 -0800)
committerReinhard Tartler <siretart@tauware.de>
Sun, 26 Feb 2012 09:03:16 +0000 (10:03 +0100)
This prevents crashers and errors further down when reading nodes in the
empty tree.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit 2b83e8b7005d531bc78b0fd4f699e9faa54ce9bb)

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavcodec/truemotion2.c

index 4045342..29d2e4d 100644 (file)
@@ -132,7 +132,7 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
                huff.val_bits, huff.max_bits);
         return -1;
     }
-    if((huff.nodes < 0) || (huff.nodes > 0x10000)) {
+    if((huff.nodes <= 0) || (huff.nodes > 0x10000)) {
         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes);
         return -1;
     }