Skip to content

Commit dddbca6

Browse files
lacatoiredevnexen
authored andcommitted
ext/gd: report $size with the argument number of the function called
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. Also fix the upper bound itself: (double)LONG_MAX rounds up to 2^63, so (double)LONG_MAX / 64 is 2^57 and the check let 2^57 through, whose product with 64 is LONG_MAX + 1. The bound is now exclusive, and the reported values use integer division, which gives the largest size that is actually representable. The lower bound stays inclusive: (double)LONG_MIN / 64 is exactly -2^57 and its product with 64 is LONG_MIN. Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Close GH-23541
1 parent 0bf872b commit dddbca6

3 files changed

Lines changed: 74 additions & 3 deletions

File tree

ext/gd/gd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,14 +3422,16 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode)
34223422
im = php_gd_libgdimageptr_from_zval_p(IM);
34233423
}
34243424