Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid uint64_t overflow in Decimal::operator/() and fix static MaxCoe…
…fficient value Avoid uint64_t overflow in Decimal::operator/() and fix static MaxCoefficient value https://bugs.webkit.org/show_bug.cgi?id=248784 Reviewed by Darin Adler. Merge - https://src.chromium.org/viewvc/blink?view=revision&revision=191294 & https://src.chromium.org/viewvc/blink?view=revision&revision=174294 This patch changes Decimal::operator/() not to cause uint64_t overflow in multiplication and addition during calculating quotient. Original code wrongly assumed each division loop generate at most two digits, by |MaxCoefficient < 100|, however this assumption is wrong such as 50,000 / 99,9999. This patch also fixes assertion failure |n> Precision|, where |Precision| == 18, in |scaleUp(x, n)| via |Decimal::ceil()|. Before this patch, we don't have 18 digits quotient with 10^-18 exponent from result of division operator. Additionally, it also update MaxCoefficient static variable value in Decimal.cpp to match the Precision and the corresponding comment about using 18 as precision. * Source/WebCore/platform/Decimal.cpp: - Update "MaxCoefficient" static variable (Decimal:operator/): Update "divisor" function to account for overflow in multiplication and addition (Decimal::ceiling): Fixes assertion failure * LayoutTests/fast/range/input-range-progress-indicator-overflow.html: Add Test Case * LayoutTests/fast/range/input-range-progress-indicator-overflow-expected.html: Add Test Case Expectation Canonical link: https://commits.webkit.org/258174@main
- Loading branch information