From dea41f3c3a003a22893b27eead429f963d3230c3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 6 Sep 2017 23:30:53 +0200 Subject: [PATCH] Fixed bug #44995 (bcpowmod() fails if scale != 0) `bc_divmod()` is supposed to do integer division, so we must not apply a scale factor here. --- NEWS | 3 +++ ext/bcmath/libbcmath/src/divmod.c | 2 +- ext/bcmath/tests/bug44995.phpt | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 ext/bcmath/tests/bug44995.phpt diff --git a/NEWS b/NEWS index 3bb2a0791a5..377f4d15406 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ PHP NEWS - Core: . Fixed #75042 run-tests.php issues with EXTENSION block). (John Boehr) +- BCMath: + . Fixed bug #44995 (bcpowmod() fails if scale != 0). (cmb) + - CLI server: . Fixed bug #70470 (Built-in server truncates headers spanning over TCP packets). (bouk) diff --git a/ext/bcmath/libbcmath/src/divmod.c b/ext/bcmath/libbcmath/src/divmod.c index d7aaa3509da..08c2f8a2a2d 100644 --- a/ext/bcmath/libbcmath/src/divmod.c +++ b/ext/bcmath/libbcmath/src/divmod.c @@ -59,7 +59,7 @@ bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale) bc_init_num(&temp); /* Calculate it. */ - bc_divide (num1, num2, &temp, scale); + bc_divide (num1, num2, &temp, 0); if (quot) quotient = bc_copy_num (temp); bc_multiply (temp, num2, &temp, rscale); diff --git a/ext/bcmath/tests/bug44995.phpt b/ext/bcmath/tests/bug44995.phpt new file mode 100644 index 00000000000..6eb591f92b7 --- /dev/null +++ b/ext/bcmath/tests/bug44995.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #44995 (bcpowmod() fails if scale != 0) +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +string(3) "1.0" +string(7) "17334.0" +===DONE===