[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Wed, 11 Nov 2026 06:43:01 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143564@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-11-11T06:41:47Z Commit: https://github.com/php/php-src/commit/764ab599a2e8712b180f4706227bb88d03d63f3a Raw diff: https://github.com/php/php-src/commit/764ab599a2e8712b180f4706227bb88d03d63f3a.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/gd: blame the points array when a polygon has too few points Changed paths: A ext/gd/tests/imagepolygon_too_few_points_argument.phpt M ext/gd/gd.c Diff: diff --git a/ext/gd/gd.c b/ext/gd/gd.c index bf14f3cdc5e6..2ac763824436 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2850,7 +2850,12 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) nelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS)); if (npoints < 3) { - zend_argument_value_error(3, "must be greater than or equal to 3"); + if (COL_IS_NULL) { + /* The count comes from the array, argument #3 is the color */ + zend_argument_value_error(2, "must have at least 3 points"); + } else { + zend_argument_value_error(3, "must be greater than or equal to 3"); + } RETURN_THROWS(); } diff --git a/ext/gd/tests/imagepolygon_too_few_points_argument.phpt b/ext/gd/tests/imagepolygon_too_few_points_argument.phpt new file mode 100644 index 000000000000..a3ccb3d279d6 --- /dev/null +++ b/ext/gd/tests/imagepolygon_too_few_points_argument.phpt @@ -0,0 +1,27 @@ +--TEST-- +imagepolygon(), imageopenpolygon(), imagefilledpolygon(): too few points blames the points array +--EXTENSIONS-- +gd +--FILE-- +<?php +$im = imagecreatetruecolor(20, 20); +foreach (['imagepolygon', 'imageopenpolygon', 'imagefilledpolygon'] as $f) { + try { + $f($im, [1, 1, 2, 2], 0xffffff); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; + } + try { + @$f($im, [1, 1, 2, 2], 2, 0xffffff); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; + } +} +?> +--EXPECT-- +ValueError: imagepolygon(): Argument #2 ($points) must have at least 3 points +ValueError: imagepolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3 +ValueError: imageopenpolygon(): Argument #2 ($points) must have at least 3 points +ValueError: imageopenpolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3 +ValueError: imagefilledpolygon(): Argument #2 ($points) must have at least 3 points +ValueError: imagefilledpolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3

« previous php.cvs (#143564) next »