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

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix GH-20006: Power of 0 of BcMath number causes UB
This commit is contained in:
Niels Dossche
2025-09-30 14:47:48 +02:00
2 changed files with 22 additions and 1 deletions

View File

@@ -193,7 +193,12 @@ bc_raise_status bc_raise(bc_num base, long exponent, bc_num *result, size_t scal
if (bc_is_zero(base)) {
/* If the exponent is negative, it divides by 0 */
return is_neg ? BC_RAISE_STATUS_DIVIDE_BY_ZERO : BC_RAISE_STATUS_OK;
if (is_neg) {
return BC_RAISE_STATUS_DIVIDE_BY_ZERO;
}
bc_free_num (result);
*result = bc_copy_num(BCG(_zero_));
return BC_RAISE_STATUS_OK;
}
/* check overflow */

View File

@@ -0,0 +1,16 @@
--TEST--
GH-20006 (Power of 0 of BcMath number causes crash)
--EXTENSIONS--
bcmath
--FILE--
<?php
$n = new BcMath\Number("0");
var_dump(pow($n, 2));
?>
--EXPECTF--
object(BcMath\Number)#%d (2) {
["value"]=>
string(1) "0"
["scale"]=>
int(0)
}