com php-src: Fixed bug #44995 (bcpowmod() fails if scale != 0): NEWS ext/bcmath/libbcmath/src/divmod.c ext/bcmath/tests/bug44995.phpt

From: Date: Wed, 06 Sep 2017 21:30:53 +0000
Subject: com php-src: Fixed bug #44995 (bcpowmod() fails if scale != 0): NEWS ext/bcmath/libbcmath/src/divmod.c ext/bcmath/tests/bug44995.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99290@lists.php.net to get a copy of this message
Commit: dea41f3c3a003a22893b27eead429f963d3230c3 Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 6 Sep 2017 23:30:53 +0200 Parents: 42549b7844472a896dbd51b8305a835e731ecb25 Branches: PHP-7.0 PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dea41f3c3a003a22893b27eead429f963d3230c3 Log: 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. Bugs: https://bugs.php.net/44995 Changed paths: M NEWS M ext/bcmath/libbcmath/src/divmod.c A ext/bcmath/tests/bug44995.phpt Diff: diff --git a/NEWS b/NEWS index 3bb2a07..377f4d1 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 d7aaa35..08c2f8a 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 0000000..6eb591f --- /dev/null +++ b/ext/bcmath/tests/bug44995.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #44995 (bcpowmod() fails if scale != 0) +--SKIPIF-- +<?php +if (!extension_loaded('bcmath')) die('skip bcmath extension not available'); +?> +--FILE-- +<?php +var_dump(bcpowmod('4', '4', '3', 1)); +var_dump(bcpowmod('3234', '32345', '22345', 1)); +?> +===DONE=== +--EXPECT-- +string(3) "1.0" +string(7) "17334.0" +===DONE===

« previous php.cvs (#99290) next »