avcodec/dpx: Move need_align to act per line
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 14 Nov 2015 13:29:02 +0000 (14:29 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 14 Nov 2015 15:12:15 +0000 (16:12 +0100)
Fixes out of array read
Fixes: 61cf123c081ee2bb774d307c75bdb99e/asan_heap-oob_1224f76_5546_bee833ffae73f752b489b9eeaac52db7.dpx

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dpx.c

index 15c939f..af7276a 100644 (file)
@@ -348,11 +348,11 @@ static int decode_frame(AVCodecContext *avctx,
                 // For 12 bit, ignore alpha
                 if (elements == 4)
                     buf += 2;
-                // Jump to next aligned position
-                buf += need_align;
             }
             for (i = 0; i < 3; i++)
                 ptr[i] += p->linesize[i];
+            // Jump to next aligned position
+            buf += need_align;
         }
         break;
     case 16: