[Webkit-unassigned] [Bug 262057] Properly clamp INT_MIN for legacy CJK counter style algorithms

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 19 14:58:50 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=262057

--- Comment #2 from Ahmad Saleem <ahmad.saleem792 at gmail.com> ---
Tried following:

static int absoluteValueForLegacyCJKAlogrithms(int value)
{
    // @counter-style algorithm works on absolute value, but the legacy
    // implementation works on the original value (and handles negative sign on
    // its own). Clamp to the signed int range before proceeding.
    if (UNLIKELY(value == std::numeric_limits<int>::min()))
        return std::numeric_limits<int>::max();
    else
        return std::abs(value);
}

and then 'return' modified like this:

return counterForSystemCJK(absoluteValueForLegacyCJKAlogrithms(value), simplifiedChineseInformalTable, Formality::Informal);

and then 'CSSCounterStyle::initialRepresentation' updated to have following as 'absoluteValue':

unsigned absoluteValue = value == std::numeric_limits<int>::min() ? static_cast<unsigned>(std::numeric_limits<int>::max()) + 1u : std::abs(value);

___

Following does not fix the test case (at least running via JSFiddle).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20231219/1a56d26f/attachment-0001.htm>


More information about the webkit-unassigned mailing list