targa: Fix y check in advance_line
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 9 Feb 2013 19:49:32 +0000 (20:49 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 19 Feb 2013 00:28:24 +0000 (01:28 +0100)
Fixes out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 796012af6c780b5b13ebca39a491f215515a18fe)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/targa.c

index 6bb05a9..321441c 100644 (file)
@@ -40,7 +40,7 @@ static uint8_t *advance_line(uint8_t *start, uint8_t *line,
         return line + interleave * stride;
     } else {
         *y = (*y + 1) & (interleave - 1);
-        if (*y) {
+        if (*y && *y < h) {
             return start + *y * stride;
         } else {
             return NULL;