mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
This commit is contained in:
commit
0f88a49fd5
3 changed files with 32 additions and 8 deletions
1
NEWS
1
NEWS
|
@ -7,6 +7,7 @@ PHP NEWS
|
||||||
|
|
||||||
- BCMath:
|
- BCMath:
|
||||||
. Fixed bug #44995 (bcpowmod() fails if scale != 0). (cmb)
|
. Fixed bug #44995 (bcpowmod() fails if scale != 0). (cmb)
|
||||||
|
. Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1). (okano1220, cmb)
|
||||||
|
|
||||||
- CLI server:
|
- CLI server:
|
||||||
. Fixed bug #70470 (Built-in server truncates headers spanning over TCP
|
. Fixed bug #70470 (Built-in server truncates headers spanning over TCP
|
||||||
|
|
|
@ -75,6 +75,12 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale)
|
||||||
|
|
||||||
/* Do the calculation. */
|
/* Do the calculation. */
|
||||||
rscale = MAX(scale, base->n_scale);
|
rscale = MAX(scale, base->n_scale);
|
||||||
|
if ( !bc_compare(mod, BCG(_one_)) )
|
||||||
|
{
|
||||||
|
temp = bc_new_num (1, scale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
while ( !bc_is_zero(exponent) )
|
while ( !bc_is_zero(exponent) )
|
||||||
{
|
{
|
||||||
(void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0);
|
(void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0);
|
||||||
|
@ -87,6 +93,7 @@ bc_raisemod (bc_num base, bc_num expo, bc_num mod, bc_num *result, int scale)
|
||||||
bc_multiply (power, power, &power, rscale);
|
bc_multiply (power, power, &power, rscale);
|
||||||
(void) bc_modulo (power, mod, &power, scale);
|
(void) bc_modulo (power, mod, &power, scale);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Assign the value. */
|
/* Assign the value. */
|
||||||
bc_free_num (&power);
|
bc_free_num (&power);
|
||||||
|
|
16
ext/bcmath/tests/bug54598.phpt
Normal file
16
ext/bcmath/tests/bug54598.phpt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #54598 (bcpowmod() may return 1 if modulus is 1)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('bcmath')) die('skip bcmath extension is not available');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
var_dump(bcpowmod(5, 0, 1));
|
||||||
|
var_dump(bcpowmod(5, 0, 1, 3));
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
string(1) "0"
|
||||||
|
string(5) "0.000"
|
||||||
|
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue