Skip to content

ext/gd: report $size with the argument number of the function called - #23541

Open
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/gd-ftbbox-size-arg-num-upstream
Open

ext/gd: report $size with the argument number of the function called#23541
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/gd-ftbbox-size-arg-num-upstream

Conversation

@lacatoire

@lacatoire lacatoire commented Sep 2, 2026

Copy link
Copy Markdown
Member

php_imagettftext_common() backs four functions with two signatures: $size is argument 1 of imageftbbox() and imagettfbbox(), and 2 of imagefttext() and imagettftext(), which take the image first. Both size checks hardcode 2, so the bbox pair blames $angle:

imageftbbox(NAN, 0.0, $font, 'A');
// ValueError: imageftbbox(): Argument #2 ($angle) must be finite

$angle was 0.0. The type error for the same parameter already says #1, since that one comes from the arginfo:

imageftbbox('x', 0.0, $font, 'A');
// TypeError: imageftbbox(): Argument #1 ($size) must be of type float, string given

The number is now derived from the mode the helper was called in; the drawing pair keeps 2.

The added test covers all four functions, in the order the checks run: the range test precedes the finite test, so INF reports "must be between" while NAN, false against both bounds, falls through to "must be finite".

Only the two bbox messages change, so this targets master.

@lacatoire
lacatoire requested a review from devnexen as a code owner September 2, 2026 12:00
@lacatoire
lacatoire force-pushed the fix/gd-ftbbox-size-arg-num-upstream branch from 5729cf3 to dfa7818 Compare September 2, 2026 12:31
Comment thread ext/gd/gd.c Outdated
php_imagettftext_common() serves the bbox functions, where $size is
argument #1, and the drawing ones, where it is #2, but its two size
checks hardcode 2. imageftbbox(NAN, ...) therefore blamed $angle.
@lacatoire
lacatoire force-pushed the fix/gd-ftbbox-size-arg-num-upstream branch from dfa7818 to 5f0cd02 Compare September 2, 2026 13:12
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