aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-03 20:15:52 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-05 14:20:32 +0200
commit43881c773277c90ccb0dbfd2d5c3afd8f8603597 (patch)
treed31081b12d9fdfb87c2d943165d321cb0640d318 /libavcodec
parent42bdcebf3360fca957e8224ff0a6573b05dbc249 (diff)
downloadffmpeg-43881c773277c90ccb0dbfd2d5c3afd8f8603597.tar.gz
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> (cherry picked from commit 8f1457864be8fb9653643519dea1c6492f1dde57) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/gifdec.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 78c8900628..6d9b926b05 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -258,26 +258,21 @@ static int gif_read_image(GifState *s, AVFrame *frame)
case 1:
y1 += 8;
ptr += linesize * 8;
- if (y1 >= height) {
- y1 = pass ? 2 : 4;
- ptr = ptr1 + linesize * y1;
- pass++;
- }
break;
case 2:
y1 += 4;
ptr += linesize * 4;
- if (y1 >= height) {
- y1 = 1;
- ptr = ptr1 + linesize;
- pass++;
- }
break;
case 3:
y1 += 2;
ptr += linesize * 2;
break;
}
+ while (y1 >= height) {
+ y1 = 4 >> pass;
+ ptr = ptr1 + linesize * y1;
+ pass++;
+ }
} else {
ptr += linesize;
}