Do planar copy with a single memcpy only if the stride is equal to the length
authormstorsjo <mstorsjo@b3059339-0415-0410-9bf9-f77b7e298cf2>
Mon, 19 Jul 2010 07:02:31 +0000 (07:02 +0000)
committermstorsjo <mstorsjo@b3059339-0415-0410-9bf9-f77b7e298cf2>
Mon, 19 Jul 2010 07:02:31 +0000 (07:02 +0000)
This avoids writing outside of the designated rectangle.

git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@31756 b3059339-0415-0410-9bf9-f77b7e298cf2

libswscale/swscale.c

index b589131..0340e80 100644 (file)
@@ -1663,10 +1663,10 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[
                     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;