From 77c555ef4565bf9e909e8162b1fd7e962d140149 Mon Sep 17 00:00:00 2001 From: dirk Date: Sun, 23 Oct 2016 11:58:32 +0200 Subject: [PATCH] Fixed incorrect access in unsharp mask kernel. --- MagickCore/accelerate-kernels-private.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/MagickCore/accelerate-kernels-private.h b/MagickCore/accelerate-kernels-private.h index 0949c3961..1c2422c2f 100644 --- a/MagickCore/accelerate-kernels-private.h +++ b/MagickCore/accelerate-kernels-private.h @@ -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); + } } ) -- 2.40.0