Skip to content

Report the upper bound in the imagecreate() and imagecreatetruecolor() size errors - #25386

Closed
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/gd-imagecreate-size-bounds-message-master
Closed

lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/gd-imagecreate-size-bounds-message-master

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

imagecreate() and imagecreatetruecolor() reject a width or height of INT_MAX or more with "must be greater than 0", which is false for every positive value rejected on the upper side. Add the upper bound to the message.

imagecreate(PHP_INT_MAX, 1);

Before: ValueError: imagecreate(): Argument #1 ($width) must be greater than 0

After: ValueError: imagecreate(): Argument #1 ($width) must be greater than 0 and less than 2147483647

imagecreate() and imagecreatetruecolor() reject a width or height of
INT_MAX or more with "must be greater than 0", which is false for
every positive value rejected on the upper side.
@devnexen devnexen closed this in 66c0f52 Nov 12, 2026
@felixbuenemann

felixbuenemann commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This caused a 32-bit test failure fixed by #25423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants