mirror of
https://github.com/php/php-src.git
synced 2025-01-26 13:44:22 +08:00
Throw warnings when using zero modulus in gmp_powm
Also fixes a leak in this case.
This commit is contained in:
parent
f10d194c8c
commit
15c139b99a
@ -1484,10 +1484,9 @@ ZEND_FUNCTION(gmp_powm)
|
||||
FETCH_GMP_ZVAL_DEP_DEP(gmpnum_mod, mod_arg, temp_mod, temp_exp, temp_base);
|
||||
|
||||
if (!mpz_cmp_ui(gmpnum_mod, 0)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Modulus may not be zero");
|
||||
FREE_GMP_TEMP(temp_base);
|
||||
if (use_ui) {
|
||||
FREE_GMP_TEMP(temp_exp);
|
||||
}
|
||||
FREE_GMP_TEMP(temp_exp);
|
||||
FREE_GMP_TEMP(temp_mod);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ var_dump(gmp_strval(gmp_powm($n,$e,1000)));
|
||||
$m = gmp_init(900);
|
||||
var_dump(gmp_strval(gmp_powm($n,$e,$m)));
|
||||
|
||||
var_dump(gmp_powm(5, 11, 0));
|
||||
var_dump(gmp_powm(5, "11", gmp_init(0)));
|
||||
|
||||
var_dump(gmp_powm(array(),$e,$m));
|
||||
var_dump(gmp_powm($n,array(),$m));
|
||||
var_dump(gmp_powm($n,$e,array()));
|
||||
@ -46,6 +49,12 @@ string(3) "331"
|
||||
string(3) "171"
|
||||
string(3) "371"
|
||||
|
||||
Warning: gmp_powm(): Modulus may not be zero in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmp_powm(): Modulus may not be zero in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
|
||||
bool(false)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user