]> granicus.if.org Git - php/commitdiff
raise ValueError from imagecreate/imagecreatetruecolor
authorPeter Cowburn <salathe@php.net>
Wed, 4 Sep 2019 20:42:43 +0000 (21:42 +0100)
committerPeter Cowburn <salathe@php.net>
Mon, 9 Sep 2019 20:06:00 +0000 (21:06 +0100)
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.

ext/gd/gd.c
ext/gd/tests/imagecreate_error.phpt
ext/gd/tests/imagecreatetruecolor_error2.phpt

index b0215386d982a24fe03129ccbd2bec3ab2b1bbd8..608f350c2f57607c58f41709c1bb4c3eca96ef65 100644 (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;
        }
 
index 127c43ec57e17cdfc801b5d34075c941257b27d8..9fd8679c135a46691132d5f104d0ad9cc960ec1e 100644 (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)
index 55252533b3e649418e4f4dfad8d1ad9d61cccbd5..e2784b15307ff95f194817ae4149b8dd712a50cf 100644 (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)