comparison huffyuv.c @ 9906:fe4e6d8242d4 libavcodec

Make sure we dont read over the end. Fixes issue1237.
author michael
date Wed, 01 Jul 2009 20:30:37 +0000
parents f1f5e78cf0aa
children 2fb2e212318b
comparison
equal deleted inserted replaced
9905:f3ff182e9ecf 9906:fe4e6d8242d4
727 static void decode_422_bitstream(HYuvContext *s, int count){ 727 static void decode_422_bitstream(HYuvContext *s, int count){
728 int i; 728 int i;
729 729
730 count/=2; 730 count/=2;
731 731
732 if(count >= (s->gb.size_in_bits - get_bits_count(&s->gb))/(31*4)){
733 for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){
734 READ_2PIX(s->temp[0][2*i ], s->temp[1][i], 1);
735 READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2);
736 }
737 }else{
732 for(i=0; i<count; i++){ 738 for(i=0; i<count; i++){
733 READ_2PIX(s->temp[0][2*i ], s->temp[1][i], 1); 739 READ_2PIX(s->temp[0][2*i ], s->temp[1][i], 1);
734 READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2); 740 READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2);
735 } 741 }
742 }
736 } 743 }
737 744
738 static void decode_gray_bitstream(HYuvContext *s, int count){ 745 static void decode_gray_bitstream(HYuvContext *s, int count){
739 int i; 746 int i;
740 747
741 count/=2; 748 count/=2;
742 749
750 if(count >= (s->gb.size_in_bits - get_bits_count(&s->gb))/(31*2)){
751 for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){
752 READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0);
753 }
754 }else{
743 for(i=0; i<count; i++){ 755 for(i=0; i<count; i++){
744 READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0); 756 READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0);
757 }
745 } 758 }
746 } 759 }
747 760
748 #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER 761 #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
749 static int encode_422_bitstream(HYuvContext *s, int offset, int count){ 762 static int encode_422_bitstream(HYuvContext *s, int offset, int count){