avcodec/gifdec: factorize interleave end handling out

also change it to a loop
Fixes out of array access
Fixes: asan_heap-oob_ca5410_8_asan_heap-oob_ca5410_97_ID_LSD_Size_Less_Then_Data_Inter_3.gif

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/87/head
Michael Niedermayer 11 years ago
parent e7e5114c50
commit 8f1457864b
  1. 15
      libavcodec/gifdec.c

@ -271,26 +271,21 @@ static int gif_read_image(GifState *s, AVFrame *frame)
case 1: case 1:
y1 += 8; y1 += 8;
ptr += linesize * 8; ptr += linesize * 8;
if (y1 >= height) {
y1 = pass ? 2 : 4;
ptr = ptr1 + linesize * y1;
pass++;
}
break; break;
case 2: case 2:
y1 += 4; y1 += 4;
ptr += linesize * 4; ptr += linesize * 4;
if (y1 >= height) {
y1 = 1;
ptr = ptr1 + linesize;
pass++;
}
break; break;
case 3: case 3:
y1 += 2; y1 += 2;
ptr += linesize * 2; ptr += linesize * 2;
break; break;
} }
while (y1 >= height) {
y1 = 4 >> pass;
ptr = ptr1 + linesize * y1;
pass++;
}
} else { } else {
ptr += linesize; ptr += linesize;
} }

Loading…
Cancel
Save