Move bcmath_check_scale()

This commit is contained in:
Niels Dossche 2024-09-06 21:19:18 +02:00
parent f1b4e1276c
commit 2e88916b58

View file

@ -148,6 +148,15 @@ PHP_MINFO_FUNCTION(bcmath)
} }
/* }}} */ /* }}} */
static zend_always_inline zend_result bcmath_check_scale(zend_long scale, uint32_t arg_num)
{
if (UNEXPECTED(scale < 0 || scale > INT_MAX)) {
zend_argument_value_error(arg_num, "must be between 0 and %d", INT_MAX);
return FAILURE;
}
return SUCCESS;
}
static void php_long2num(bc_num *num, zend_long lval) static void php_long2num(bc_num *num, zend_long lval)
{ {
*num = bc_long2num(lval); *num = bc_long2num(lval);
@ -1305,15 +1314,6 @@ static zend_always_inline zend_result bc_num_from_obj_or_str_or_long_with_err(
return SUCCESS; return SUCCESS;
} }
static zend_always_inline zend_result bcmath_check_scale(zend_long scale, uint32_t arg_num)
{
if (UNEXPECTED(scale < 0 || scale > INT_MAX)) {
zend_argument_value_error(arg_num, "must be between 0 and %d", INT_MAX);
return FAILURE;
}
return SUCCESS;
}
PHP_METHOD(BcMath_Number, __construct) PHP_METHOD(BcMath_Number, __construct)
{ {
zend_string *str = NULL; zend_string *str = NULL;