Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ext/bcmath/libbcmath/src/raise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
16 changes: 16 additions & 0 deletions ext/bcmath/tests/gh20006.phpt
Original file line number Diff line number Diff line change
@@ -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)
}