Skip to content

Commit

Permalink
REGRESSION(277450@main): OOB array read with SVG animation where keyP…
Browse files Browse the repository at this point in the history
…oints = 0.

https://bugs.webkit.org/show_bug.cgi?id=272929
rdar://126636733

Reviewed by Said Abou-Hallawa.

This change makes a couple additional, similar changes to the original changes
to better track the SVG spec. (See the original bug for more information.)

* LayoutTests/svg/animations/animate-zero-keyPoints-should-not-crash-expected.txt: Added.
* LayoutTests/svg/animations/animate-zero-keyPoints-should-not-crash.html: Added.
* Source/WebCore/svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::keyTimes const):
(WebCore::SVGAnimationElement::startedActiveInterval):

Canonical link: https://commits.webkit.org/278212@main
  • Loading branch information
mscottapple authored and Said Abou-Hallawa committed May 1, 2024
1 parent 70e44fd commit 53e67f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Passes if it does not crash.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<body>
<svg zoomAndPan="magnify">
<text>
Passes if it does not crash.
<animateMotion path="m 1,0" keyPoints="0" keyTimes="0" restart="always"/>
</text>
</svg>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
</body>
4 changes: 2 additions & 2 deletions Source/WebCore/svg/SVGAnimationElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static inline double solveEpsilon(double duration) { return 1 / (200 * duration)

const Vector<float>& SVGAnimationElement::keyTimes() const
{
return calcMode() == CalcMode::Paced ? m_keyTimesForPaced : m_keyTimesFromAttribute;
return (calcMode() == CalcMode::Paced && animationMode() != AnimationMode::Path) ? m_keyTimesForPaced : m_keyTimesFromAttribute;
}

unsigned SVGAnimationElement::calculateKeyTimesIndex(float percent) const
Expand Down Expand Up @@ -589,7 +589,7 @@ void SVGAnimationElement::startedActiveInterval()
if (calcMode == CalcMode::Paced && m_animationValid)
calculateKeyTimesForCalcModePaced();
} else if (animationMode == AnimationMode::Path)
m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (keyTimes.size() > 1 && keyTimes.size() == m_keyPoints.size());
m_animationValid = !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (keyTimes.size() > 1 && keyTimes.size() == m_keyPoints.size());
}

void SVGAnimationElement::updateAnimation(float percent, unsigned repeatCount)
Expand Down

0 comments on commit 53e67f6

Please sign in to comment.