[FFmpeg-cvslog] r19322 - trunk/libavcodec/huffyuv.c

michael subversion
Wed Jul 1 22:30:37 CEST 2009


Author: michael
Date: Wed Jul  1 22:30:37 2009
New Revision: 19322

Log:
Make sure we dont read over the end.
Fixes issue1237.

Modified:
   trunk/libavcodec/huffyuv.c

Modified: trunk/libavcodec/huffyuv.c
==============================================================================
--- trunk/libavcodec/huffyuv.c	Wed Jul  1 22:14:19 2009	(r19321)
+++ trunk/libavcodec/huffyuv.c	Wed Jul  1 22:30:37 2009	(r19322)
@@ -729,10 +729,17 @@ static void decode_422_bitstream(HYuvCon
 
     count/=2;
 
+    if(count >= (s->gb.size_in_bits - get_bits_count(&s->gb))/(31*4)){
+        for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){
+            READ_2PIX(s->temp[0][2*i  ], s->temp[1][i], 1);
+            READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2);
+        }
+    }else{
     for(i=0; i<count; i++){
         READ_2PIX(s->temp[0][2*i  ], s->temp[1][i], 1);
         READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2);
     }
+    }
 }
 
 static void decode_gray_bitstream(HYuvContext *s, int count){
@@ -740,9 +747,15 @@ static void decode_gray_bitstream(HYuvCo
 
     count/=2;
 
+    if(count >= (s->gb.size_in_bits - get_bits_count(&s->gb))/(31*2)){
+        for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){
+            READ_2PIX(s->temp[0][2*i  ], s->temp[0][2*i+1], 0);
+        }
+    }else{
     for(i=0; i<count; i++){
         READ_2PIX(s->temp[0][2*i  ], s->temp[0][2*i+1], 0);
     }
+    }
 }
 
 #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER



More information about the ffmpeg-cvslog mailing list