Skip to content

Commit 789c050

Browse files
devnexencharmitro
authored andcommitted
Revert "ext/gmp: gmp_pow fix FPE with large values."
This reverts commit d70b781.
1 parent 8e8b5af commit 789c050

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
@@ -1366,37 +1366,12 @@ ZEND_FUNCTION(gmp_pow)
13661366

13671367
if (Z_TYPE_P(base_arg) == IS_LONG && Z_LVAL_P(base_arg) >= 0) {
13681368
INIT_GMP_RETVAL(gmpnum_result);
1369-
if (exp >= INT_MAX) {
1370-
mpz_t base_num, exp_num, mod;
1371-
mpz_init(base_num);
1372-
mpz_init(exp_num);
1373-
mpz_init(mod);
1374-
mpz_set_si(base_num, Z_LVAL_P(base_arg));
1375-
mpz_set_si(exp_num, exp);
1376-
mpz_set_ui(mod, UINT_MAX);
1377-
mpz_powm(gmpnum_result, base_num, exp_num, mod);
1378-
mpz_clear(mod);
1379-
mpz_clear(exp_num);
1380-
mpz_clear(base_num);
1381-
} else {
1382-
mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp);
1383-
}
1369+
mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp);
13841370
} else {
13851371
mpz_ptr gmpnum_base;
13861372
FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base, 1);
13871373
INIT_GMP_RETVAL(gmpnum_result);
1388-
if (exp >= INT_MAX) {
1389-
mpz_t exp_num, mod;
1390-
mpz_init(exp_num);
1391-
mpz_init(mod);
1392-
mpz_set_si(exp_num, exp);
1393-
mpz_set_ui(mod, UINT_MAX);
1394-
mpz_powm(gmpnum_result, gmpnum_base, exp_num, mod);
1395-
mpz_clear(mod);
1396-
mpz_clear(exp_num);
1397-
} else {
1398-
mpz_pow_ui(gmpnum_result, gmpnum_base, exp);
1399-
}
1374+
mpz_pow_ui(gmpnum_result, gmpnum_base, exp);
14001375
FREE_GMP_TEMP(temp_base);
14011376
}
14021377
}

ext/gmp/tests/gmp_pow_fpe.phpt

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

0 commit comments

Comments
 (0)