]> granicus.if.org Git - imagemagick/commitdiff
Fixed incorrect access in unsharp mask kernel.
authordirk <dirk@git.imagemagick.org>
Sun, 23 Oct 2016 09:58:32 +0000 (11:58 +0200)
committerdirk <dirk@git.imagemagick.org>
Sun, 23 Oct 2016 09:58:37 +0000 (11:58 +0200)
MagickCore/accelerate-kernels-private.h

index 0949c3961e4c3dfacd691613d4cb3dc5ba631914..1c2422c2fc61845e6d779adf96c6b64c8184f57c 100644 (file)
@@ -3009,16 +3009,17 @@ OPENCL_ENDIF()
       ++i;
     }
 
-    float4 srcPixel = ReadFloat4(image, number_channels, columns, x, y, channel);
-    float4 diff = srcPixel - value;
+    if ((x < columns) && (y < rows)) {
+      float4 srcPixel = ReadFloat4(image, number_channels, columns, x, y, channel);
+      float4 diff = srcPixel - value;
 
-    float quantumThreshold = QuantumRange*threshold;
+      float quantumThreshold = QuantumRange*threshold;
 
-    int4 mask = isless(fabs(2.0f * diff), (float4)quantumThreshold);
-    value = select(srcPixel + diff * gain, srcPixel, mask);
+      int4 mask = isless(fabs(2.0f * diff), (float4)quantumThreshold);
+      value = select(srcPixel + diff * gain, srcPixel, mask);
 
-    if ((x < columns) && (y < rows))
       WriteFloat4(filteredImage, number_channels, columns, x, y, channel, value);
+    }
   }
   )