| Summary: | Properly clamp INT_MIN for legacy CJK counter style algorithms | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
| Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Normal | CC: | karlcow, ntim, vitor.roriz, webkit-bug-importer |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
|
Description
Ahmad Saleem
2023-09-25 11:04:06 PDT
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).
|