From: Peter Cowburn Date: Wed, 4 Sep 2019 20:42:43 +0000 (+0100) Subject: raise ValueError from imagecreate/imagecreatetruecolor X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a43679632b97b513d6e2913d90e24d0915e1b486;p=php raise ValueError from imagecreate/imagecreatetruecolor Raise a ValueError instead of a plain Error when calling imagecreate() or imagecreatetruecolor() with too big or small values for the width or height arguments. --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index b0215386d9..608f350c2f 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -829,12 +829,12 @@ PHP_FUNCTION(imagecreatetruecolor) } if (x_size <= 0 || x_size >= INT_MAX) { - zend_throw_error(NULL, "Invalid width (x_size)"); + zend_value_error("Invalid width (x_size)"); return; } if (y_size <= 0 || y_size >= INT_MAX) { - zend_throw_error(NULL, "Invalid height (y_size)"); + zend_value_error("Invalid height (y_size)"); return; } @@ -1473,12 +1473,12 @@ PHP_FUNCTION(imagecreate) } if (x_size <= 0 || x_size >= INT_MAX) { - zend_throw_error(NULL, "Invalid width (x_size)"); + zend_value_error("Invalid width (x_size)"); return; } if (y_size <= 0 || y_size >= INT_MAX) { - zend_throw_error(NULL, "Invalid height (y_size)"); + zend_value_error("Invalid height (y_size)"); return; } diff --git a/ext/gd/tests/imagecreate_error.phpt b/ext/gd/tests/imagecreate_error.phpt index 127c43ec57..9fd8679c13 100644 --- a/ext/gd/tests/imagecreate_error.phpt +++ b/ext/gd/tests/imagecreate_error.phpt @@ -17,5 +17,5 @@ trycatch_dump( ?> --EXPECT-- -!! [Error] Invalid width (x_size) -!! [Error] Invalid height (y_size) +!! [ValueError] Invalid width (x_size) +!! [ValueError] Invalid height (y_size) diff --git a/ext/gd/tests/imagecreatetruecolor_error2.phpt b/ext/gd/tests/imagecreatetruecolor_error2.phpt index 55252533b3..e2784b1530 100644 --- a/ext/gd/tests/imagecreatetruecolor_error2.phpt +++ b/ext/gd/tests/imagecreatetruecolor_error2.phpt @@ -19,5 +19,5 @@ trycatch_dump( ?> --EXPECT-- -!! [Error] Invalid width (x_size) -!! [Error] Invalid height (y_size) +!! [ValueError] Invalid width (x_size) +!! [ValueError] Invalid height (y_size)