diff --git a/NEWS b/NEWS index e722a0d3ec7..c78b4b1b6a8 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ PHP NEWS - DOM: . Fixed bug GH-14343 (Memory leak in xml and dom). (nielsdos) +- GD: + . Fix parameter numbers for imagecolorset(). (Giovanni Giacobbi) + - Intl: . Fix reference handling in SpoofChecker. (nielsdos) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 509a5e47606..ef5bc9a03a3 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2216,9 +2216,9 @@ PHP_FUNCTION(imagecolorset) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red, 2); - CHECK_RGBA_RANGE(green, Green, 3); - CHECK_RGBA_RANGE(blue, Blue, 4); + CHECK_RGBA_RANGE(red, Red, 3); + CHECK_RGBA_RANGE(green, Green, 4); + CHECK_RGBA_RANGE(blue, Blue, 5); col = color; diff --git a/ext/gd/tests/imagecolorset_error1.phpt b/ext/gd/tests/imagecolorset_error1.phpt new file mode 100644 index 00000000000..6509501b49d --- /dev/null +++ b/ext/gd/tests/imagecolorset_error1.phpt @@ -0,0 +1,26 @@ +--TEST-- +imagecolorset() parameters errors +--EXTENSIONS-- +gd +--FILE-- + imagecolorset($im, $c, -3, 4, 5, 6), + fn() => imagecolorset($im, $c, 3, -4, 5, 6), + fn() => imagecolorset($im, $c, 3, 4, -5, 6), + fn() => imagecolorset($im, $c, 3, 4, 5, -6), +); + +?> +--EXPECT-- +!! [ValueError] imagecolorset(): Argument #3 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorset(): Argument #4 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorset(): Argument #5 ($blue) must be between 0 and 255 (inclusive) +NULL