Skip to content

Commit 972f582

Browse files
committed
add test
1 parent bf0c2a8 commit 972f582

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ext/gmp/gmp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,7 @@ ZEND_FUNCTION(gmp_pow)
12901290
INIT_GMP_RETVAL(gmpnum_result);
12911291
gmpnum = mpz_get_ui(gmpnum_base);
12921292
if ((log10(gmpnum) * exp) > (double)ULONG_MAX) {
1293+
FREE_GMP_TEMP(temp_base);
12931294
zend_value_error("base and exponent overflow");
12941295
RETURN_THROWS();
12951296
}

ext/gmp/tests/gmp_pow_fpe.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
gmp_pow() floating point exception
3+
--EXTENSIONS--
4+
gmp
5+
--FILE--
6+
<?php
7+
$g = gmp_init(256);
8+
9+
try {
10+
gmp_pow($g, PHP_INT_MAX);
11+
} catch (\ValueError $e) {
12+
echo $e->getMessage() . PHP_EOL;
13+
}
14+
try {
15+
gmp_pow(256, PHP_INT_MAX);
16+
} catch (\ValueError $e) {
17+
echo $e->getMessage();
18+
}
19+
?>
20+
--EXPECT--
21+
base and exponent overflow
22+
base and exponent overflow

0 commit comments

Comments
 (0)