Skip to content

Commit

Permalink
Fix undefined behavior caused by a null clip path element #209
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Jan 7, 2025
1 parent dbbe1f3 commit 5101088
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/svgelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ void SVGClipPathElement::applyClipPath(SVGRenderState& state) const
shapeElement = toSVGGeometryElement(element->firstChild());
}

if(shapeElement == nullptr || shapeElement->isDisplayNone() || shapeElement->isVisibilityHidden())
if(shapeElement == nullptr || !shapeElement->isRenderable())
continue;
state->clipPath(shapeElement->path(), shapeElement->clip_rule(), clipTransform * shapeElement->localTransform());
return;
Expand Down Expand Up @@ -1070,7 +1070,7 @@ bool SVGClipPathElement::requiresMasking() const
shapeElement = toSVGGeometryElement(element->firstChild());
}

if(shapeElement == nullptr || shapeElement->isDisplayNone() || shapeElement->isVisibilityHidden())
if(shapeElement == nullptr || !shapeElement->isRenderable())
continue;
if(prevShapeElement || shapeElement->clipper())
return true;
Expand Down
2 changes: 1 addition & 1 deletion source/svggeometryelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void SVGGeometryElement::updateMarkerPositions(SVGMarkerPositionList& positions,

void SVGGeometryElement::render(SVGRenderState& state) const
{
if(m_path.isNull() || isVisibilityHidden() || isDisplayNone())
if(!isRenderable())
return;
SVGBlendInfo blendInfo(this);
SVGRenderState newState(this, state, localTransform());
Expand Down
2 changes: 2 additions & 0 deletions source/svggeometryelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class SVGGeometryElement : public SVGGraphicsElement {
Rect strokeBoundingBox() const override;
void layoutElement(const SVGLayoutState& state) override;

bool isRenderable() const { return !m_path.isNull() && !isDisplayNone() && !isVisibilityHidden(); }

FillRule fill_rule() const { return m_fill_rule; }
FillRule clip_rule() const { return m_clip_rule; }

Expand Down

0 comments on commit 5101088

Please sign in to comment.