Merge branch 'PHP-8.4'

* PHP-8.4:
  Fixed GH-16978: Avoid unnecessary padding with leading zeros (#16988)
This commit is contained in:
Saki Takamachi 2024-11-29 21:28:48 +09:00
commit 5930278702
No known key found for this signature in database
GPG key ID: 770426E17EBBB3DD
2 changed files with 13 additions and 0 deletions

View file

@ -436,6 +436,7 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
numerator_bottom_extension = 0; numerator_bottom_extension = 0;
numeratorend -= scale_diff > numerator_top_extension ? scale_diff - numerator_top_extension : 0; numeratorend -= scale_diff > numerator_top_extension ? scale_diff - numerator_top_extension : 0;
} }
numerator_top_extension = MIN(numerator_top_extension, scale);
} else { } else {
numerator_bottom_extension += scale - numerator_scale; numerator_bottom_extension += scale - numerator_scale;
} }

View file

@ -0,0 +1,12 @@
--TEST--
GH-16978 Stack buffer overflow ext/bcmath/libbcmath/src/div.c:464:12 in bc_divide
--EXTENSIONS--
bcmath
--FILE--
<?php
echo bcpow('10', '-112', 10) . "\n";
echo bcdiv('1', '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 1);
?>
--EXPECT--
0.0000000000
0.0