Bug 250384
| Summary: | Potential Assertion Fix - newStartAngle >= 0 && newStartAngle < twoPiFloat | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
| Component: | Canvas | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | dino, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Ahmad Saleem
Hi Team,
While going through Blink's commit, I came across following potential assertion fix:
Blink Commit - https://chromium.googlesource.com/chromium/blink/+/651895c0233495405847471d42dab20deab2a0f3
WebKit Source - https://github.com/WebKit/WebKit/blob/28de25b653f64ca3fc8e87fbf1d1a963329a5342/Source/WebCore/html/canvas/CanvasPath.cpp#L143
Unfortunately, it does not have any test case to confirm whether it is an issue in Safari / WebKit or not but just wanted to get an input.
Thanks!
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/104332195>
Ahmad Saleem
This compiles:
tatic void normalizeAngles(float& startAngle, float& endAngle, bool anticlockwise)
{
float newStartAngle = fmodf(startAngle, (2 * piFloat));
if (newStartAngle < 0)
newStartAngle += (2 * piFloat);
Ahmad Saleem
If we add this:
constexpr auto twoPiFloat = 2 * piFloat;
we can simplify whole function:
static void normalizeAngles(float& startAngle, float& endAngle, bool anticlockwise)
{
constexpr auto twoPiFloat = 2 * piFloat;
float newStartAngle = fmodf(startAngle, twoPiFloat);
if (newStartAngle < 0)
newStartAngle += twoPiFloat;
float delta = newStartAngle - startAngle;
startAngle = newStartAngle;
endAngle = endAngle + delta;
ASSERT(newStartAngle >= 0 && (newStartAngle < twoPiFloat || WTF::areEssentiallyEqual<float>(newStartAngle, twoPiFloat)));
if (anticlockwise && startAngle - endAngle >= twoPiFloat)
endAngle = startAngle - twoPiFloat;
else if (!anticlockwise && endAngle - startAngle >= twoPiFloat)
endAngle = startAngle + twoPiFloat;
}
Ahmad Saleem
PR attempt - https://github.com/WebKit/WebKit/pull/19657
EWS
Committed 269925@main (34e0f2e73041): <https://commits.webkit.org/269925@main>
Reviewed commits have been landed. Closing PR #19657 and removing active labels.