Skip to content

Commit c7bdf30

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

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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. */
@@ -65,7 +66,7 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul
6566
bc_init_num(&parity);
6667

6768
/* Do the calculation. */
68-
if (!bc_compare(modulus, BCG(_one_))) {
69+
if (!_bc_do_compare(modulus, BCG(_one_), false)) {
6970
bc_free_num (&temp);
7071
temp = bc_new_num (1, scale);
7172
} 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)