Blame SOURCES/ImageMagick-splice-crash.patch

b7c072
diff -up ImageMagick-6.7.8-9/magick/transform.c.splice-crash ImageMagick-6.7.8-9/magick/transform.c
b7c072
--- ImageMagick-6.7.8-9/magick/transform.c.splice-crash	2012-06-20 15:03:21.000000000 +0200
b7c072
+++ ImageMagick-6.7.8-9/magick/transform.c	2016-06-02 17:40:43.860641940 +0200
b7c072
@@ -65,6 +65,7 @@
b7c072
 #include "magick/string_.h"
b7c072
 #include "magick/thread-private.h"
b7c072
 #include "magick/transform.h"
b7c072
+#define MagickMin(x,y) (((x) < (y)) ? (x) : (y))
b7c072
 
b7c072
 /*
b7c072
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b7c072
@@ -1646,6 +1647,7 @@ MagickExport Image *SpliceImage(const Im
b7c072
     splice_geometry;
b7c072
 
b7c072
   ssize_t
b7c072
+    columns,
b7c072
     y;
b7c072
 
b7c072
   /*
b7c072
@@ -1730,6 +1732,7 @@ MagickExport Image *SpliceImage(const Im
b7c072
   */
b7c072
   status=MagickTrue;
b7c072
   progress=0;
b7c072
+  columns=MagickMin(splice_geometry.x,(ssize_t) splice_image->columns);
b7c072
   image_view=AcquireVirtualCacheView(image,exception);
b7c072
   splice_view=AcquireAuthenticCacheView(splice_image,exception);
b7c072
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
b7c072
@@ -1753,7 +1756,8 @@ MagickExport Image *SpliceImage(const Im
b7c072
 
b7c072
     if (status == MagickFalse)
b7c072
       continue;
b7c072
-    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
b7c072
+    p=GetCacheViewVirtualPixels(image_view,0,y,splice_image->columns,1,
b7c072
+      exception);
b7c072
     q=QueueCacheViewAuthenticPixels(splice_view,0,y,splice_image->columns,1,
b7c072
       exception);
b7c072
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
b7c072
@@ -1763,7 +1767,7 @@ MagickExport Image *SpliceImage(const Im
b7c072
       }
b7c072
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
b7c072
     splice_indexes=GetCacheViewAuthenticIndexQueue(splice_view);
b7c072
-    for (x=0; x < splice_geometry.x; x++)
b7c072
+    for (x=0; x < columns; x++)
b7c072
     {
b7c072
       SetPixelRed(q,GetPixelRed(p));
b7c072
       SetPixelGreen(q,GetPixelGreen(p));
b7c072
@@ -1833,10 +1837,10 @@ MagickExport Image *SpliceImage(const Im
b7c072
 
b7c072
     if (status == MagickFalse)
b7c072
       continue;
b7c072
-    p=GetCacheViewVirtualPixels(image_view,0,y-(ssize_t) splice_geometry.height,
b7c072
-      image->columns,1,exception);
b7c072
-    if ((y < 0) || (y >= (ssize_t) splice_image->rows))
b7c072
+    if ((y < 0) || (y >= (ssize_t)splice_image->rows))
b7c072
       continue;
b7c072
+    p=GetCacheViewVirtualPixels(image_view,0,y-(ssize_t) splice_geometry.height,
b7c072
+      splice_image->columns,1,exception);
b7c072
     q=QueueCacheViewAuthenticPixels(splice_view,0,y,splice_image->columns,1,
b7c072
       exception);
b7c072
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
b7c072
@@ -1846,7 +1850,7 @@ MagickExport Image *SpliceImage(const Im
b7c072
       }
b7c072
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
b7c072
     splice_indexes=GetCacheViewAuthenticIndexQueue(splice_view);
b7c072
-    for (x=0; x < splice_geometry.x; x++)
b7c072
+    for (x=0; x < columns; x++)
b7c072
     {
b7c072
       SetPixelRed(q,GetPixelRed(p));
b7c072
       SetPixelGreen(q,GetPixelGreen(p));