summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-23 16:10:08 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-07-23 22:17:40 +0200
commit2a1e975f4fa67162f3c7b37939fa0a3b771376f5 (patch)
treef9517445cd32a4fa9c046c8017642c896ea9acf8 /svgio
parent8b1208d0b931fbac9cbbf593a2044d63b2933d8b (diff)
crashtesting: infinite recurse with moz455984-5.svg
Change-Id: Idef368c44454ae144b091132cd0d6103f92a6dde Reviewed-on: https://gerrit.libreoffice.org/57854 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
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;