Skip to content

Commit ba7b305

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: ext/bcmath: Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0)
2 parents edc1309 + 709869c commit ba7b305

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ PHP NEWS
77
. Fixed bug GH-12814 (max_execution_time reached too early on MacOS 14
88
when running on Apple Silicon). (Manuel Kress)
99

10+
- BCMatch:
11+
. Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0). (Girgias)
12+
1013
- Curl:
1114
. Fixed bug GH-14307 (Test curl_basic_024 fails with curl 8.8.0). (nielsdos)
1215

ext/bcmath/libbcmath/src/raisemod.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*************************************************************************/
3131

3232
#include "bcmath.h"
33+
#include "private.h"
3334
#include <stddef.h>
3435

3536
/* Raise BASE to the EXPO power, reduced modulo MOD. The result is placed in RESULT. */
@@ -67,7 +68,7 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul
6768

6869
/* Do the calculation. */
6970
rscale = MAX(scale, power->n_scale);
70-
if (!bc_compare(modulus, BCG(_one_))) {
71+
if (!_bc_do_compare(modulus, BCG(_one_), false, false)) {
7172
bc_free_num (&temp);
7273
temp = bc_new_num (1, scale);
7374
} else {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
bcpowmod() must return 0 when mod is +1 or -1
3+
--EXTENSIONS--
4+
bcmath
5+
--FILE--
6+
<?php
7+
var_dump(bcpowmod(5, 0, 1));
8+
var_dump(bcpowmod(5, 0, 1, 3));
9+
var_dump(bcpowmod(5, 0, -1));
10+
var_dump(bcpowmod(5, 0, -1, 3));
11+
?>
12+
--EXPECT--
13+
string(1) "0"
14+
string(5) "0.000"
15+
string(1) "0"
16+
string(5) "0.000"

0 commit comments

Comments
 (0)