Skip to content

Commit 52fe9b0

Browse files
committed
Fix GH-16354 convert GMP to number failure.
zend_parse_arg_long_slow/zend_null_arg_deprecated handle nullable as 2nd (or +) argument so here we trigger a TypeError exception in case we deal with null at 1st argument.
1 parent c34d4fb commit 52fe9b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ext/gmp/gmp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,15 @@ static zend_result convert_to_gmp(mpz_t gmpnumber, zval *val, zend_long base, ui
619619
case IS_STRING: {
620620
return convert_zstr_to_gmp(gmpnumber, Z_STR_P(val), base, arg_pos);
621621
}
622+
case IS_NULL: {
623+
/**
624+
* zend_parse_arg_long_slow support nullable argument but expects it
625+
* to be the 2nd, and onward, argument or non null but at any place.
626+
**/
627+
zend_type_error(
628+
"Number must be of type GMP|string|int, null given");
629+
return FAILURE;
630+
}
622631
default: {
623632
zend_long lval;
624633
if (!zend_parse_arg_long_slow(val, &lval, arg_pos)) {

0 commit comments

Comments
 (0)