Clamp scale in bc_is_zero_for_scale to n_scale - #220
Open
iliaal wants to merge 1 commit into
Open
Conversation
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
force-pushed
the
fix/bcmath-zero-scale-clamp
branch
from
August 5, 2026 12:15
c78d058 to
c5411a2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.