From 6a05e42459e0b5ae0c202f6500d50a8c18820385 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 4 Sep 2019 01:42:28 +0200 Subject: [PATCH] Warnings to Errors imagetruecolortopalette --- ext/gd/gd.c | 5 +++-- ext/gd/tests/bug72697.phpt | 12 +++++++++--- ext/gd/tests/imagetruecolortopalette_error3.phpt | 12 +++++++++--- ext/gd/tests/imagetruecolortopalette_error4.phpt | 15 +++++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 75bbb1da9d..83d5d1301a 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -885,9 +885,10 @@ PHP_FUNCTION(imagetruecolortopalette) } if (ncolors <= 0 || ZEND_LONG_INT_OVFL(ncolors)) { - php_error_docref(NULL, E_WARNING, "Number of colors has to be greater than zero and no more than %d", INT_MAX); - RETURN_FALSE; + zend_throw_error(NULL, "Number of colors has to be greater than zero and no more than %d", INT_MAX); + return; } + if (gdImageTrueColorToPalette(im, dither, (int)ncolors)) { RETURN_TRUE; } else { diff --git a/ext/gd/tests/bug72697.phpt b/ext/gd/tests/bug72697.phpt index 97bd3bdf88..5608d5f17b 100644 --- a/ext/gd/tests/bug72697.phpt +++ b/ext/gd/tests/bug72697.phpt @@ -8,10 +8,16 @@ if (PHP_INT_MAX !== 9223372036854775807) die("skip for 64-bit long systems only" --FILE-- imagetruecolortopalette($img, false, PHP_INT_MAX / 8) +); + ?> DONE ---EXPECTF-- -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than 2147483647 in %sbug72697.php on line %d +--EXPECT-- +!! [Error] Number of colors has to be greater than zero and no more than 2147483647 DONE diff --git a/ext/gd/tests/imagetruecolortopalette_error3.phpt b/ext/gd/tests/imagetruecolortopalette_error3.phpt index 2a256ba957..180e947b63 100644 --- a/ext/gd/tests/imagetruecolortopalette_error3.phpt +++ b/ext/gd/tests/imagetruecolortopalette_error3.phpt @@ -9,8 +9,14 @@ Rafael Dohms ?> --FILE-- imagetruecolortopalette($image, true, null) +); + ?> ---EXPECTF-- -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s on line %d +--EXPECT-- +!! [Error] Number of colors has to be greater than zero and no more than 2147483647 diff --git a/ext/gd/tests/imagetruecolortopalette_error4.phpt b/ext/gd/tests/imagetruecolortopalette_error4.phpt index 2db042e89f..ed1345e7ed 100644 --- a/ext/gd/tests/imagetruecolortopalette_error4.phpt +++ b/ext/gd/tests/imagetruecolortopalette_error4.phpt @@ -9,13 +9,16 @@ Rafael Dohms ?> --FILE-- imagetruecolortopalette($image, true, 0), + fn() => imagetruecolortopalette($image, true, -1) +); ?> ---EXPECTF-- -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s line %d - -Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s line %d +--EXPECT-- +!! [Error] Number of colors has to be greater than zero and no more than 2147483647 +!! [Error] Number of colors has to be greater than zero and no more than 2147483647 -- 2.40.0