if (zend_parse_parameters(ZEND_NUM_ARGS(), "pllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
return;
}
- if (width < 1 || height < 1) {
- php_error_docref(NULL, E_WARNING, "Zero width or height not allowed");
- RETURN_FALSE;
+
+ if (width < 1) {
+ zend_throw_error(NULL, "Width must be at least 1");
+ return;
}
+
+ if (height < 1) {
+ zend_throw_error(NULL, "Height must be at least 1");
+ return;
+ }
+
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &file, &file_len) == FAILURE) {
return;
?>
--FILE--
<?php
+require __DIR__ . '/func.inc';
+
$file = __DIR__ . '/bug38212私はガラスを食べられます.gd2';
$im1 = imagecreatetruecolor(10,100);
imagefill($im1, 0,0, 0xffffff);
imagegd2($im1, $file);
-$im = imagecreatefromgd2part($file, 0,0, -25,10);
+
+trycatch_dump(
+ fn() => imagecreatefromgd2part($file, 0,0, -25, 10),
+ fn() => imagecreatefromgd2part($file, 0,0, 10, -25)
+);
+
unlink($file);
?>
---EXPECTF--
-Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
+--EXPECT--
+!! [Error] Width must be at least 1
+!! [Error] Height must be at least 1
?>
--FILE--
<?php
+require __DIR__ . '/func.inc';
+
$file = __DIR__ . '/bug38212.gd2';
$im1 = imagecreatetruecolor(10,100);
imagefill($im1, 0,0, 0xffffff);
imagegd2($im1, $file);
-$im = imagecreatefromgd2part($file, 0,0, -25,10);
+
+trycatch_dump(
+ fn() => imagecreatefromgd2part($file, 0,0, -25, 10),
+ fn() => imagecreatefromgd2part($file, 0,0, 10, -25)
+);
+
unlink($file);
?>
---EXPECTF--
-Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
+--EXPECT--
+!! [Error] Width must be at least 1
+!! [Error] Height must be at least 1
+++ /dev/null
---TEST--
-Bug #39508 (imagefill crashes with small images 3 pixels or less)
---SKIPIF--
-<?php
- if (!extension_loaded('gd')) die("skip gd extension not available\n");
-?>
---FILE--
-<?php
-$img =imagecreatefromgd2part("foo私はガラスを食べられます.png",0, 100, 0, 100);
-?>
---EXPECTF--
-Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
+++ /dev/null
---TEST--
-Bug #39508 (imagefill crashes with small images 3 pixels or less)
---SKIPIF--
-<?php
- if (!extension_loaded('gd')) die("skip gd extension not available\n");
-?>
---FILE--
-<?php
-$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100);
-?>
---EXPECTF--
-Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d