Skip to content

Clamp scale in bc_is_zero_for_scale to n_scale - #23185

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/bcmath-zero-scale-clamp
Open

Clamp scale in bc_is_zero_for_scale to n_scale#23185
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/bcmath-zero-scale-clamp

Conversation

@iliaal

@iliaal iliaal commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

bc_is_zero_for_scale walked n_len+scale digits without clamping scale to n_scale. Opposite-sign Number::compare with an explicit scale can call it when one operand is shorter, reading past the digit buffer. Match bc_is_near_zero and clamp first.

Number::compare() may request a scale greater than the stored scale of a
zero result when the opposite operand has a larger scale. The helper then
walked past the shorter digit buffer.

Clamp the requested scale to the digits stored in the number.

Closes phpGH-23185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant