Skip to content

Commit a436796

Browse files
committed
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.
1 parent bc61997 commit a436796

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

ext/gd/gd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,12 @@ PHP_FUNCTION(imagecreatetruecolor)
829829
}
830830

831831
if (x_size <= 0 || x_size >= INT_MAX) {
832-
zend_throw_error(NULL, "Invalid width (x_size)");
832+
zend_value_error("Invalid width (x_size)");
833833
return;
834834
}
835835

836836
if (y_size <= 0 || y_size >= INT_MAX) {
837-
zend_throw_error(NULL, "Invalid height (y_size)");
837+
zend_value_error("Invalid height (y_size)");
838838
return;
839839
}
840840

@@ -1473,12 +1473,12 @@ PHP_FUNCTION(imagecreate)
14731473
}
14741474

14751475
if (x_size <= 0 || x_size >= INT_MAX) {
1476-
zend_throw_error(NULL, "Invalid width (x_size)");
1476+
zend_value_error("Invalid width (x_size)");
14771477
return;
14781478
}
14791479

14801480
if (y_size <= 0 || y_size >= INT_MAX) {
1481-
zend_throw_error(NULL, "Invalid height (y_size)");
1481+
zend_value_error("Invalid height (y_size)");
14821482
return;
14831483
}
14841484

ext/gd/tests/imagecreate_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ trycatch_dump(
1717

1818
?>
1919
--EXPECT--
20-
!! [Error] Invalid width (x_size)
21-
!! [Error] Invalid height (y_size)
20+
!! [ValueError] Invalid width (x_size)
21+
!! [ValueError] Invalid height (y_size)

ext/gd/tests/imagecreatetruecolor_error2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ trycatch_dump(
1919

2020
?>
2121
--EXPECT--
22-
!! [Error] Invalid width (x_size)
23-
!! [Error] Invalid height (y_size)
22+
!! [ValueError] Invalid width (x_size)
23+
!! [ValueError] Invalid height (y_size)

0 commit comments

Comments
 (0)