https://github.com/ImageMagick/ImageMagick/issues/818
diff --git a/MagickCore/effect.c b/MagickCore/effect.c
index 26763c2..614ae37 100644
--- a/MagickCore/effect.c
+++ b/MagickCore/effect.c
@@ -2851,6 +2851,10 @@
if ((cos_theta == (double *) NULL) ||
(sin_theta == (double *) NULL))
{
+ if (cos_theta != (double *) NULL)
+ cos_theta=(double *) RelinquishMagickMemory(cos_theta);
+ if (sin_theta != (double *) NULL)
+ sin_theta=(double *) RelinquishMagickMemory(sin_theta);
blur_image=DestroyImage(blur_image);
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
}