1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3'

* PHP-8.3:
  ext/bcmath: Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0)
This commit is contained in:
Gina Peter Banyard
2024-05-30 15:52:45 +01:00
2 changed files with 18 additions and 1 deletions

View File

@@ -30,6 +30,7 @@
*************************************************************************/
#include "bcmath.h"
#include "private.h"
#include <stddef.h>
/* 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
bc_init_num(&parity);
/* Do the calculation. */
if (!bc_compare(modulus, BCG(_one_))) {
if (!_bc_do_compare(modulus, BCG(_one_), false)) {
bc_free_num (&temp);
temp = bc_new_num (1, scale);
} else {

View File

@@ -0,0 +1,16 @@
--TEST--
bcpowmod() must return 0 when mod is +1 or -1
--EXTENSIONS--
bcmath
--FILE--
<?php
var_dump(bcpowmod(5, 0, 1));
var_dump(bcpowmod(5, 0, 1, 3));
var_dump(bcpowmod(5, 0, -1));
var_dump(bcpowmod(5, 0, -1, 3));
?>
--EXPECT--
string(1) "0"
string(5) "0.000"
string(1) "0"
string(5) "0.000"