Skip to content

Commit

Permalink
Crash in SVGGeometryElement::isPointInFill
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=265802
rdar://119142303

Reviewed by Ryosuke Niwa.

Check for empty objects.

* LayoutTests/fast/svg/isPointInFill-without-path-expected.txt: Added.
* LayoutTests/fast/svg/isPointInFill-without-path.html: Added.
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.cpp:
(WebCore::LegacyRenderSVGShape::shapeDependentFillContains const):

Canonical link: https://commits.webkit.org/273494@main
  • Loading branch information
achristensen07 committed Jan 25, 2024
1 parent 268bc37 commit 89b5637
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions LayoutTests/fast/svg/isPointInFill-without-path-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONSOLE MESSAGE: Error: Invalid value for <rect> attribute y="1 -1 62"
CONSOLE MESSAGE: Error: Invalid negative value for <rect> attribute width="-1cm"
ALERT: This test passes if it does not crash

10 changes: 10 additions & 0 deletions LayoutTests/fast/svg/isPointInFill-without-path.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
if (window.testRunner) { testRunner.dumpAsText() }
function checkPointInFill() {
var result = rectElement.isPointInFill();
alert("This test passes if it does not crash");
}
</script>
<body onload=checkPointInFill()>
<svg id="svgElement" transform="skewY(0)" style="font-variant-caps: titling-case; rotation: 0deg; text-decoration-upright: all none; box-ordinal-group: 1; grid-template: none/-1px" xml:space="default" baseProfile="full" xml:space="preserve" preserveAlpha="true" points="1,1 12,0" x="1em" role="button" role="button">
<rect id="rectElement" x="20em" y="1 -1 62" width="-1cm" height="1cm" font-size="4px" transform="skewX(-1) skewX(6)" fill="url(#doesnotexist) currentColor" clip-path="url(#svgElement)" repeatDur="4s" vert-origin-y="10" onclick="eventhandler4()" refX="56" fx="1" />
2 changes: 2 additions & 0 deletions Source/WebCore/rendering/svg/RenderSVGRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point, PointC

bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const WindRule fillRule) const
{
if (m_shapeType == ShapeType::Empty)
return false;
if (m_shapeType != ShapeType::Rectangle)
return RenderSVGShape::shapeDependentFillContains(point, fillRule);
return m_fillBoundingBox.contains(point.x(), point.y());
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ bool LegacyRenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point,

bool LegacyRenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const WindRule fillRule) const
{
if (m_shapeType == ShapeType::Empty)
return false;
if (m_shapeType != ShapeType::Rectangle)
return LegacyRenderSVGShape::shapeDependentFillContains(point, fillRule);
return m_fillBoundingBox.contains(point.x(), point.y());
Expand Down

0 comments on commit 89b5637

Please sign in to comment.