Skip to content

Commit 5101088

Browse files
committed
Fix undefined behavior caused by a null clip path element #209
1 parent dbbe1f3 commit 5101088

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

source/svgelement.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ void SVGClipPathElement::applyClipPath(SVGRenderState& state) const
10411041
shapeElement = toSVGGeometryElement(element->firstChild());
10421042
}
10431043

1044-
if(shapeElement == nullptr || shapeElement->isDisplayNone() || shapeElement->isVisibilityHidden())
1044+
if(shapeElement == nullptr || !shapeElement->isRenderable())
10451045
continue;
10461046
state->clipPath(shapeElement->path(), shapeElement->clip_rule(), clipTransform * shapeElement->localTransform());
10471047
return;
@@ -1070,7 +1070,7 @@ bool SVGClipPathElement::requiresMasking() const
10701070
shapeElement = toSVGGeometryElement(element->firstChild());
10711071
}
10721072

1073-
if(shapeElement == nullptr || shapeElement->isDisplayNone() || shapeElement->isVisibilityHidden())
1073+
if(shapeElement == nullptr || !shapeElement->isRenderable())
10741074
continue;
10751075
if(prevShapeElement || shapeElement->clipper())
10761076
return true;

source/svggeometryelement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void SVGGeometryElement::updateMarkerPositions(SVGMarkerPositionList& positions,
138138

139139
void SVGGeometryElement::render(SVGRenderState& state) const
140140
{
141-
if(m_path.isNull() || isVisibilityHidden() || isDisplayNone())
141+
if(!isRenderable())
142142
return;
143143
SVGBlendInfo blendInfo(this);
144144
SVGRenderState newState(this, state, localTransform());

source/svggeometryelement.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class SVGGeometryElement : public SVGGraphicsElement {
3636
Rect strokeBoundingBox() const override;
3737
void layoutElement(const SVGLayoutState& state) override;
3838

39+
bool isRenderable() const { return !m_path.isNull() && !isDisplayNone() && !isVisibilityHidden(); }
40+
3941
FillRule fill_rule() const { return m_fill_rule; }
4042
FillRule clip_rule() const { return m_clip_rule; }
4143

0 commit comments

Comments
 (0)