Skip to content

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

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

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.
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.

2 participants