Skip to content

Clamp scale in bc_is_zero_for_scale to n_scale - #220

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

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

Conversation

@iliaal

@iliaal iliaal commented Aug 5, 2026

Copy link
Copy Markdown
Owner

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.
@iliaal
iliaal force-pushed the fix/bcmath-zero-scale-clamp branch from c78d058 to c5411a2 Compare August 5, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant