Fix std::accumulate truncating float values in parseKeyTimes assertion#61569
Merged
Conversation
Collaborator
|
EWS run on current version of this PR (hash 4d2dccd) Details |
graouts
approved these changes
Mar 29, 2026
https://bugs.webkit.org/show_bug.cgi?id=310972 rdar://173577708 Reviewed by Antoine Quint. The ASSERT used 0 (int) as the initial value, causing all float values to be truncated to int during accumulation, making the assertion always trivially pass. Use 0.0f instead. * Source/WebCore/svg/SVGAnimationElement.cpp: (WebCore::parseKeyTimes): Canonical link: https://commits.webkit.org/310175@main
4d2dccd to
4e73e06
Compare
Collaborator
|
Committed 310175@main (4e73e06): https://commits.webkit.org/310175@main Reviewed commits have been landed. Closing PR #61569 and removing active labels. |
shallawa
reviewed
Mar 30, 2026
|
|
||
| if (verifyOrder && !result.isEmpty() && !result.last()) { | ||
| ASSERT(!std::accumulate(result.begin(), result.end(), 0)); | ||
| ASSERT(!std::accumulate(result.begin(), result.end(), 0.0f)); |
Contributor
There was a problem hiding this comment.
I am not sure what the purpose of this change is. This ASSERT is in fact checks if all the elements of result are zeros. If verifyOrder is true and the last element of result is zero, then all the elements before it must be zeros. Elements of result cannot be negative since we return if time is negative:
if (!ok || time < 0 || time > 1)
return { };
And a time can't be added unless it is in order:
if (verifyOrder && (result.isEmpty() ? time : time < result.last()))
return { };
Maybe using std::all_of() would make the purpose of this ASSERT clearer.
Contributor
Author
There was a problem hiding this comment.
@shallawa - Something like this?
ASSERT(std::all_of(result.begin(), result.end(), [](float time) { return !time; }));
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
4e73e06
4d2dccd