Skip to content

ext/bcmath: bc_divide() small fix #18060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged
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
16 changes: 5 additions & 11 deletions ext/bcmath/libbcmath/src/div.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,11 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
while (*numeratorptr == 0) {
numeratorptr++;
numerator_leading_zeros++;
if (numerator_leading_zeros == numerator_size) {
goto quot_zero;
}
}
if (numerator_size > numerator_leading_zeros) {
numerator_size -= numerator_leading_zeros;
} else {
goto quot_zero;
}
numerator_size -= numerator_leading_zeros;

/* check and remove divisor leading zeros */
while (*divisorptr == 0) {
Expand All @@ -396,12 +395,7 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale)
divisor_trailing_zeros++;
}
divisor_size -= divisor_trailing_zeros;

if (numerator_size > divisor_trailing_zeros) {
numerator_size -= divisor_trailing_zeros;
} else {
goto quot_zero;
}
numerator_size -= divisor_trailing_zeros;

size_t quot_size = numerator_size - divisor_size + 1; /* numerator_size >= divisor_size */
if (quot_size > quot_scale) {
Expand Down
Loading