diff --git a/imagick_class.c b/imagick_class.c index 9f17d661..7ac55e5b 100644 --- a/imagick_class.c +++ b/imagick_class.c @@ -13492,8 +13492,12 @@ PHP_METHOD(Imagick, colorThresholdImage) return; stop_color_wand = php_imagick_zval_to_pixelwand (stop_color_param, IMAGICK_CLASS, &stop_color_allocated TSRMLS_CC); - if (!stop_color_wand) + if (!stop_color_wand) { + if (start_color_allocated) + start_color_wand = DestroyPixelWand (start_color_wand); + return; + } status = MagickColorThresholdImage( intern->magick_wand, diff --git a/package.xml b/package.xml index ff2d3222..d7952ac6 100644 --- a/package.xml +++ b/package.xml @@ -390,6 +390,7 @@ This extension requires ImageMagick version 6.5.3-10+ and PHP 5.6.0+. + diff --git a/tests/313_Imagick_colorThresholdImage_invalid.phpt b/tests/313_Imagick_colorThresholdImage_invalid.phpt new file mode 100644 index 00000000..87439d45 --- /dev/null +++ b/tests/313_Imagick_colorThresholdImage_invalid.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test Imagick, colorThresholdImage invalid input +--SKIPIF-- + +--FILE-- +colorThresholdImage( + "rgb(10, 10, 10)", + "complete garbage" + ); + } catch (ImagickException $e) { + echo "ImagickException: ", $e->getMessage(), "\n"; + } +} + +colorThresholdImage() ; +?> +--EXPECTF-- +ImagickException: Unrecognized color string