Skip to content

Commit 7e8d6f9

Browse files
committed
Revert "ext/gmp: gmp_pow fix FPE with large values."
This reverts commit d70b781.
1 parent 45140e5 commit 7e8d6f9

File tree

3 files changed

+2
-49
lines changed

3 files changed

+2
-49
lines changed

NEWS

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ PHP NEWS
129129
(nielsdos)
130130

131131
- GMP:
132-
. Fixed floating point exception bug with gmp_pow when using
133-
large exposant values. (David Carlier).
134132
. Fixed bug GH-16411 (gmp_export() can cause overflow). (cmb)
135133
. Fixed bug GH-16501 (gmp_random_bits() can cause overflow).
136134
(David Carlier)

ext/gmp/gmp.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,37 +1352,12 @@ ZEND_FUNCTION(gmp_pow)
13521352

13531353
if (Z_TYPE_P(base_arg) == IS_LONG && Z_LVAL_P(base_arg) >= 0) {
13541354
INIT_GMP_RETVAL(gmpnum_result);
1355-
if (exp >= INT_MAX) {
1356-
mpz_t base_num, exp_num, mod;
1357-
mpz_init(base_num);
1358-
mpz_init(exp_num);
1359-
mpz_init(mod);
1360-
mpz_set_si(base_num, Z_LVAL_P(base_arg));
1361-
mpz_set_si(exp_num, exp);
1362-
mpz_set_ui(mod, UINT_MAX);
1363-
mpz_powm(gmpnum_result, base_num, exp_num, mod);
1364-
mpz_clear(mod);
1365-
mpz_clear(exp_num);
1366-
mpz_clear(base_num);
1367-
} else {
1368-
mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp);
1369-
}
1355+
mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp);
13701356
} else {
13711357
mpz_ptr gmpnum_base;
13721358
FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base, 1);
13731359
INIT_GMP_RETVAL(gmpnum_result);
1374-
if (exp >= INT_MAX) {
1375-
mpz_t exp_num, mod;
1376-
mpz_init(exp_num);
1377-
mpz_init(mod);
1378-
mpz_set_si(exp_num, exp);
1379-
mpz_set_ui(mod, UINT_MAX);
1380-
mpz_powm(gmpnum_result, gmpnum_base, exp_num, mod);
1381-
mpz_clear(mod);
1382-
mpz_clear(exp_num);
1383-
} else {
1384-
mpz_pow_ui(gmpnum_result, gmpnum_base, exp);
1385-
}
1360+
mpz_pow_ui(gmpnum_result, gmpnum_base, exp);
13861361
FREE_GMP_TEMP(temp_base);
13871362
}
13881363
}

ext/gmp/tests/gmp_pow_fpe.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)