changeset 31690:f2d98fc0702c

Do planar copy with a single memcpy only if the stride is equal to the length This avoids writing outside of the designated rectangle.
author mstorsjo
date Mon, 19 Jul 2010 07:02:31 +0000
parents c447fb125915
children d53473c681ac
files libswscale/swscale.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libswscale/swscale.c	Mon Jul 19 00:12:08 2010 +0000
+++ b/libswscale/swscale.c	Mon Jul 19 07:02:31 2010 +0000
@@ -1663,10 +1663,10 @@
                     srcPtr+= srcStride[plane];
                     dstPtr+= dstStride[plane];
                 }
-            } else if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0) {
-                if (height > 0)
+            } else if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0 &&
+                       srcStride[plane] == length) {
                     memcpy(dst[plane] + dstStride[plane]*y, src[plane],
-                           (height - 1)*dstStride[plane] + length);
+                           height*dstStride[plane]);
             } else {
                 if(is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
                     length*=2;