]> git.sesse.net Git - ffmpeg/commitdiff
swscale: prevent invalid writes in packed_16bpc_bswap
authorJanne Grunau <janne-libav@jannau.net>
Mon, 26 Dec 2011 12:38:39 +0000 (13:38 +0100)
committerJanne Grunau <janne-libav@jannau.net>
Mon, 26 Dec 2011 14:50:17 +0000 (15:50 +0100)
Writes past the end of the destination buffer were occuring when its
stride was smaller than the stride of the source. Fixes Bug #183.

libswscale/swscale_unscaled.c

index 34b0f246f14effb21aa12755fcfef36a314ae8d6..7c339b6c059451cb4b262e3bfcb9a4eacb18bba3 100644 (file)
@@ -285,9 +285,10 @@ static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[],
     int dststr = dstStride[0] >> 1;
     uint16_t       *dstPtr =       (uint16_t *) dst[0];
     const uint16_t *srcPtr = (const uint16_t *) src[0];
+    int min_stride         = FFMIN(srcstr, dststr);
 
     for (i = 0; i < srcSliceH; i++) {
-        for (j = 0; j < srcstr; j++) {
+        for (j = 0; j < min_stride; j++) {
             dstPtr[j] = av_bswap16(srcPtr[j]);
         }
         srcPtr += srcstr;