Commit 3c97f164ac5 for php
commit 3c97f164ac572df3a633eb37d5f605ee2ac3c774
Author: Marc Bennewitz <marc-mabe@users.noreply.github.com>
Date: Mon Nov 2 16:39:33 2026 +0100
Fix imagetruecolortopalette() error message for $num_colors (#24780)
The message claimed that $num_colors must be less than INT_MAX, while INT_MAX
itself is accepted.
diff --git a/NEWS b/NEWS
index 0dbd1376328..ff1857f443a 100644
--- a/NEWS
+++ b/NEWS
@@ -116,6 +116,9 @@ PHP NEWS
- FTP:
. Fix double free in ext/ftp data_accept() on accept failure. (alepacheco)
+- GD:
+ . Fixed imagetruecolortopalette() error message. (Marc Bennewitz)
+
- Hash:
. Fix GOST and Snefru digests of 512 MiB or more. (Martin Mirchev)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 92001c4f996..21fb90c3b4d 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -729,7 +729,7 @@ PHP_FUNCTION(imagetruecolortopalette)
im = php_gd_libgdimageptr_from_zval_p(IM);
if (ncolors <= 0 || ZEND_LONG_INT_OVFL(ncolors)) {
- zend_argument_value_error(3, "must be greater than 0 and less than %d", INT_MAX);
+ zend_argument_value_error(3, "must be between 1 and %d", INT_MAX);
RETURN_THROWS();
}
diff --git a/ext/gd/tests/bug72697.phpt b/ext/gd/tests/bug72697.phpt
index a7ab6114db3..f8c21406ba0 100644
--- a/ext/gd/tests/bug72697.phpt
+++ b/ext/gd/tests/bug72697.phpt
@@ -20,5 +20,5 @@
?>
DONE
--EXPECT--
-!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be greater than 0 and less than 2147483647
+!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be between 1 and 2147483647
DONE
diff --git a/ext/gd/tests/imagetruecolortopalette_error3.phpt b/ext/gd/tests/imagetruecolortopalette_error3.phpt
index 0cbeca7e6d8..d7726562572 100644
--- a/ext/gd/tests/imagetruecolortopalette_error3.phpt
+++ b/ext/gd/tests/imagetruecolortopalette_error3.phpt
@@ -20,4 +20,4 @@
?>
--EXPECT--
-!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be greater than 0 and less than 2147483647
+!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be between 1 and 2147483647
diff --git a/ext/gd/tests/imagetruecolortopalette_error4.phpt b/ext/gd/tests/imagetruecolortopalette_error4.phpt
index d1e8cffc39d..36b6d91b854 100644
--- a/ext/gd/tests/imagetruecolortopalette_error4.phpt
+++ b/ext/gd/tests/imagetruecolortopalette_error4.phpt
@@ -21,5 +21,5 @@
?>
--EXPECT--
-!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be greater than 0 and less than 2147483647
-!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be greater than 0 and less than 2147483647
+!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be between 1 and 2147483647
+!! [ValueError] imagetruecolortopalette(): Argument #3 ($num_colors) must be between 1 and 2147483647