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.
This commit is contained in:
Peter Cowburn 2019-09-04 21:42:43 +01:00
parent bc61997571
commit a43679632b
3 changed files with 8 additions and 8 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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)