Skip to content

Commit 64756b2

Browse files
committed
merge errors
merge errors
1 parent 32cd248 commit 64756b2

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

ext/gmp/gmp.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,11 +1206,7 @@ ZEND_FUNCTION(gmp_powm_sec)
12061206
RETURN_THROWS();
12071207
}
12081208

1209-
if (!mpz_cmp_ui(gmpnum_mod, 0)) {
1210-
zend_argument_error(zend_ce_division_by_zero_error, 3, "Modulo by zero");
1211-
RETURN_THROWS();
1212-
}
1213-
1209+
/* Zero is not odd, so this also rejects a zero modulus. */
12141210
if (!mpz_odd_p(gmpnum_mod)) {
12151211
zend_argument_value_error(3, "must be odd");
12161212
RETURN_THROWS();

ext/gmp/tests/gmp_powm_sec.phpt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ foreach ([0, -1] as $exp) {
2222
}
2323
}
2424

25-
try {
26-
var_dump(gmp_powm_sec(4, 13, 0));
27-
} catch (\DivisionByZeroError $e) {
28-
echo $e->getMessage(), \PHP_EOL;
29-
}
30-
31-
try {
32-
var_dump(gmp_powm_sec(4, 13, 496));
33-
} catch (\ValueError $e) {
34-
echo $e->getMessage(), \PHP_EOL;
25+
foreach ([0, 496] as $modulus) {
26+
try {
27+
var_dump(gmp_powm_sec(4, 13, $modulus));
28+
} catch (\ValueError $e) {
29+
echo $e->getMessage(), \PHP_EOL;
30+
}
3531
}
3632

3733
echo "Done\n";
@@ -41,6 +37,6 @@ string(3) "445"
4137
string(1) "5"
4238
gmp_powm_sec(): Argument #2 ($exponent) must be greater than 0
4339
gmp_powm_sec(): Argument #2 ($exponent) must be greater than 0
44-
gmp_powm_sec(): Argument #3 ($modulus) Modulo by zero
40+
gmp_powm_sec(): Argument #3 ($modulus) must be odd
4541
gmp_powm_sec(): Argument #3 ($modulus) must be odd
4642
Done

0 commit comments

Comments
 (0)