Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix parameter numbers for imagecolorset()
This commit is contained in:
Niels Dossche 2024-06-05 18:04:53 +02:00
commit 7fe03e1a1b
No known key found for this signature in database
GPG key ID: B8A8AD166DF0E2E5
3 changed files with 32 additions and 3 deletions

3
NEWS
View file

@ -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)

View file

@ -2212,9 +2212,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;

View file

@ -0,0 +1,26 @@
--TEST--
imagecolorset() parameters errors
--EXTENSIONS--
gd
--FILE--
<?php
require __DIR__ . '/func.inc';
$im = imagecreate(5, 5);
$c = imagecolorallocatealpha($im, 3, 4, 5, 6);
trycatch_dump(
fn() => 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