diff options
Diffstat (limited to 'ext/gmp/gmp.c')
-rw-r--r-- | ext/gmp/gmp.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 30693da5cb..ea3c6cf408 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -1365,7 +1365,16 @@ ZEND_FUNCTION(gmp_fact) RETURN_FALSE; } } else { - if (zval_get_long(a_arg) < 0) { + /* Use convert_to_number first to detect getting non-integer */ + convert_scalar_to_number(a_arg); + if (Z_TYPE_P(a_arg) != IS_LONG) { + convert_to_long(a_arg); + if (Z_LVAL_P(a_arg) >= 0) { + /* Only warn if we'll make it past the non-negative check */ + php_error_docref(NULL, E_WARNING, "Number has to be an integer"); + } + } + if (Z_LVAL_P(a_arg) < 0) { php_error_docref(NULL, E_WARNING, "Number has to be greater than or equal to 0"); RETURN_FALSE; } |