summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-23 16:10:08 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-07-26 11:24:19 +0200
commite54b0a2ada74713a9906838d60b38df6d464bacd (patch)
treed6c1aae6eac128983a73fe0b1dc4fbd7a758a23a /svgio
parentb37e31e9537fe5437809bc711edc01b6442b7bae (diff)
crashtesting: infinite recurse with moz455984-5.svg
Change-Id: Idef368c44454ae144b091132cd0d6103f92a6dde Reviewed-on: https://gerrit.libreoffice.org/57855 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgpatternnode.hxx1
-rw-r--r--svgio/source/svgreader/svgpatternnode.cxx71
2 files changed, 52 insertions, 20 deletions
diff --git a/svgio/inc/svgpatternnode.hxx b/svgio/inc/svgpatternnode.hxx
index 5aa93b373217..956c8da1812e 100644
--- a/svgio/inc/svgpatternnode.hxx
+++ b/svgio/inc/svgpatternnode.hxx
@@ -55,6 +55,7 @@ namespace svgio
/// link to another pattern used as style. If maXLink
/// is set, the node can be fetched on demand by using
// tryToFindLink (buffered)
+ mutable bool mbResolvingLink; // protect against infinite link recursion
OUString maXLink;
const SvgPatternNode* mpXLink;
diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx
index 758a6022f841..5b3d2d726abe 100644
--- a/svgio/source/svgreader/svgpatternnode.cxx
+++ b/svgio/source/svgreader/svgpatternnode.cxx
@@ -47,6 +47,7 @@ namespace svgio
mpPatternUnits(nullptr),
mpPatternContentUnits(nullptr),
mpaPatternTransform(nullptr),
+ mbResolvingLink(false),
maXLink(),
mpXLink(nullptr)
{
@@ -271,9 +272,12 @@ namespace svgio
{
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getPatternPrimitives();
+ mbResolvingLink = true;
+ const drawinglayer::primitive2d::Primitive2DContainer& ret = mpXLink->getPatternPrimitives();
+ mbResolvingLink = false;
+ return ret;
}
}
@@ -301,9 +305,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getViewBox();
+ mbResolvingLink = true;
+ auto ret = mpXLink->getViewBox();
+ mbResolvingLink = false;
+ return ret;
}
return nullptr;
@@ -318,9 +325,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getSvgAspectRatio();
+ mbResolvingLink = true;
+ const SvgAspectRatio& ret = mpXLink->getSvgAspectRatio();
+ mbResolvingLink = false;
+ return ret;
}
return maSvgAspectRatio;
@@ -335,9 +345,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getX();
+ mbResolvingLink = true;
+ const SvgNumber& ret = mpXLink->getX();
+ mbResolvingLink = false;
+ return ret;
}
return maX;
@@ -352,9 +365,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getY();
+ mbResolvingLink = true;
+ const SvgNumber& ret = mpXLink->getY();
+ mbResolvingLink = false;
+ return ret;
}
return maY;
@@ -369,9 +385,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getWidth();
+ mbResolvingLink = true;
+ const SvgNumber& ret = mpXLink->getWidth();
+ mbResolvingLink = false;
+ return ret;
}
return maWidth;
@@ -386,9 +405,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getHeight();
+ mbResolvingLink = true;
+ const SvgNumber& ret = mpXLink->getHeight();
+ mbResolvingLink = false;
+ return ret;
}
return maHeight;
@@ -403,9 +425,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getPatternUnits();
+ mbResolvingLink = true;
+ auto ret = mpXLink->getPatternUnits();
+ mbResolvingLink = false;
+ return ret;
}
return nullptr;
@@ -420,9 +445,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getPatternContentUnits();
+ mbResolvingLink = true;
+ auto ret = mpXLink->getPatternContentUnits();
+ mbResolvingLink = false;
+ return ret;
}
return nullptr;
@@ -437,9 +465,12 @@ namespace svgio
const_cast< SvgPatternNode* >(this)->tryToFindLink();
- if(mpXLink)
+ if (mpXLink && !mbResolvingLink)
{
- return mpXLink->getPatternTransform();
+ mbResolvingLink = true;
+ auto ret = mpXLink->getPatternTransform();
+ mbResolvingLink = false;
+ return ret;
}
return nullptr;