From: Mark Date: Tue, 3 Sep 2019 23:46:41 +0000 (+0200) Subject: Warnings become errors for imagepolygon et al X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34865f54e7318962947ee250ae01fceaa3d942ac;p=php Warnings become errors for imagepolygon et al --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 7dd14ab5d0..52db8cea94 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2786,16 +2786,18 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) nelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS)); if (nelem < 6) { - php_error_docref(NULL, E_WARNING, "You must have at least 3 points in your array"); - RETURN_FALSE; + zend_throw_error(NULL, "You must have at least 3 points in your array"); + return; } + if (npoints <= 0) { - php_error_docref(NULL, E_WARNING, "You must give a positive number of points"); - RETURN_FALSE; + zend_throw_error(NULL, "You must give a positive number of points"); + return; } + if (nelem < npoints * 2) { - php_error_docref(NULL, E_WARNING, "Trying to use %d points in array with only %d points", npoints, nelem/2); - RETURN_FALSE; + zend_throw_error(NULL, "Trying to use %d points in array with only %d points", npoints, nelem/2); + return; } points = (gdPointPtr) safe_emalloc(npoints, sizeof(gdPoint), 0); diff --git a/ext/gd/tests/imagefilledpolygon_negative.phpt b/ext/gd/tests/imagefilledpolygon_negative.phpt index a572a195f5..eae032d51e 100644 --- a/ext/gd/tests/imagefilledpolygon_negative.phpt +++ b/ext/gd/tests/imagefilledpolygon_negative.phpt @@ -6,10 +6,16 @@ imagefilledpolygon() with a negative num of points ?> --FILE-- imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black) +); + imagedestroy($im); ?> ---EXPECTF-- -Warning: imagefilledpolygon(): You must give a positive number of points in %s on line %d +--EXPECT-- +!! [Error] You must give a positive number of points diff --git a/ext/gd/tests/imagepolygon_negative.phpt b/ext/gd/tests/imagepolygon_negative.phpt index d122a3bbaa..8334589e38 100644 --- a/ext/gd/tests/imagepolygon_negative.phpt +++ b/ext/gd/tests/imagepolygon_negative.phpt @@ -6,10 +6,16 @@ imagepolygon() with a negative num of points ?> --FILE-- imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black) +); + imagedestroy($im); ?> ---EXPECTF-- -Warning: imagepolygon(): You must give a positive number of points in %s on line %d +--EXPECT-- +!! [Error] You must give a positive number of points