diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 8b8d6cfd848d8..b04bd18bb92c3 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2212,9 +2212,10 @@ 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); + CHECK_RGBA_RANGE(alpha, Alpha, 6); col = color; diff --git a/ext/gd/tests/imagecolorset_error1.phpt b/ext/gd/tests/imagecolorset_error1.phpt new file mode 100644 index 0000000000000..0a529f8925e98 --- /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) +!! [ValueError] imagecolorset(): Argument #6 ($alpha) must be between 0 and 127 (inclusive)