ffv1: fix integer overflow in quant table initialization
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 2 Jun 2012 00:37:36 +0000 (02:37 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 2 Jun 2012 00:37:36 +0000 (02:37 +0200)
Fixes part of Ticket1372

Found-by: Piotr Bandurski <ami_stuff@o2.pl>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/ffv1.c

index 79409e2..21f1761 100644 (file)
@@ -1651,9 +1651,9 @@ static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale){
     memset(state, 128, sizeof(state));
 
     for(v=0; i<128 ; v++){
-        int len= get_symbol(c, state, 0) + 1;
+        unsigned len= get_symbol(c, state, 0) + 1;
 
-        if(len + i > 128) return -1;
+        if(len > 128 - i) return -1;
 
         while(len--){
             quant_table[i] = scale*v;