aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-12 19:53:40 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-17 23:23:05 +0100
commit41eda870483fd1f2dc6f7f17cd68e360626180c9 (patch)
treeb8ea6918b4b0ad1a71da4382149107892e0a0aab /libavcodec
parente6ac11e41734cbb24ec5e6c73264d030e5f07a64 (diff)
downloadffmpeg-41eda870483fd1f2dc6f7f17cd68e360626180c9.tar.gz
pngdec/filter: dont access out of array elements at the end
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 1ac0fa50eff30d413206cffa5f47f7fe6d4849b1) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pngdec.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 3c6284fc10..ae932991d3 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -148,7 +148,7 @@ static void add_paeth_prediction_c(uint8_t *dst, uint8_t *src, uint8_t *top, int
if(bpp >= 2) g = dst[1];\
if(bpp >= 3) b = dst[2];\
if(bpp >= 4) a = dst[3];\
- for(; i < size; i+=bpp) {\
+ for(; i <= size - bpp; i+=bpp) {\
dst[i+0] = r = op(r, src[i+0], last[i+0]);\
if(bpp == 1) continue;\
dst[i+1] = g = op(g, src[i+1], last[i+1]);\
@@ -164,13 +164,9 @@ static void add_paeth_prediction_c(uint8_t *dst, uint8_t *src, uint8_t *top, int
else if(bpp == 2) UNROLL1(2, op)\
else if(bpp == 3) UNROLL1(3, op)\
else if(bpp == 4) UNROLL1(4, op)\
- else {\
- for (; i < size; i += bpp) {\
- int j;\
- for (j = 0; j < bpp; j++)\
- dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
- }\
- }
+ for (; i < size; i++) {\
+ dst[i] = op(dst[i-bpp], src[i], last[i]);\
+ }\
/* NOTE: 'dst' can be equal to 'last' */
static void png_filter_row(PNGDecContext *s, uint8_t *dst, int filter_type,