if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zllll", &ppfilename, &srcx, &srcy, &width, &height) == FAILURE) {
return;
}
+ if (width < 1 || height < 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Zero width or height not allowed");
+ RETURN_FALSE;
+ }
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &ppfilename) == FAILURE) {
return;
--TEST--
-imagecopy doen't copy alpha, palette to truecolor
+Bzg #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
--SKIPIF--
<?php
if (!function_exists('imagecopy')) die("skip gd extension not available\n");
unlink($file);
?>
--EXPECTF--
-Warning: imagecreatefromgd2part(): '%sbug38212.gd2' is not a valid GD2 file in %sbug38212.php on line %d
+
+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");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100);
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d