diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-07-18 12:12:05 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-07-18 15:37:16 +0200 |
commit | f35e3b36b0df830d0259d9d754c3da1946da3e6b (patch) | |
tree | 8fccb4bc57470302c4b2250ce2cb177234a554f2 /svgio | |
parent | 0197a2ca1602c3ea13fecabd9de7499971830e21 (diff) |
crashtesting: infinite recurse on moz330387-6.svg
Change-Id: I3c39d49504a4651b92f41c07e4cef8887366dc2b
Reviewed-on: https://gerrit.libreoffice.org/57626
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/svggradientnode.hxx | 1 | ||||
-rw-r--r-- | svgio/source/svgreader/svggradientnode.cxx | 75 |
2 files changed, 55 insertions, 21 deletions
diff --git a/svgio/inc/svggradientnode.hxx b/svgio/inc/svggradientnode.hxx index 3710519dc392..1542796b48fc 100644 --- a/svgio/inc/svggradientnode.hxx +++ b/svgio/inc/svggradientnode.hxx @@ -56,6 +56,7 @@ namespace svgio /// link to another gradient 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 SvgGradientNode* mpXLink; diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx index 4496a809a8cf..efbfdccaadb5 100644 --- a/svgio/source/svgreader/svggradientnode.cxx +++ b/svgio/source/svgreader/svggradientnode.cxx @@ -51,6 +51,7 @@ namespace svgio maGradientUnits(objectBoundingBox), maSpreadMethod(drawinglayer::primitive2d::SpreadMethod::Pad), mpaGradientTransform(nullptr), + mbResolvingLink(false), maXLink(), mpXLink(nullptr) { @@ -246,9 +247,11 @@ namespace svgio { const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { + mbResolvingLink = true; mpXLink->collectGradientEntries(aVector); + mbResolvingLink = false; } } else @@ -312,9 +315,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getX1(); + mbResolvingLink = true; + auto ret = mpXLink->getX1(); + mbResolvingLink = false; + return ret; } // default is 0% @@ -330,9 +336,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getY1(); + mbResolvingLink = true; + auto ret = mpXLink->getY1(); + mbResolvingLink = false; + return ret; } // default is 0% @@ -348,9 +357,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getX2(); + mbResolvingLink = true; + auto ret = mpXLink->getX2(); + mbResolvingLink = false; + return ret; } // default is 100% @@ -366,9 +378,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getY2(); + mbResolvingLink = true; + auto ret = mpXLink->getY2(); + mbResolvingLink = false; + return ret; } // default is 0% @@ -384,9 +399,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getCx(); + mbResolvingLink = true; + auto ret = mpXLink->getCx(); + mbResolvingLink = false; + return ret; } // default is 50% @@ -402,9 +420,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getCy(); + mbResolvingLink = true; + auto ret = mpXLink->getCy(); + mbResolvingLink = false; + return ret; } // default is 50% @@ -420,9 +441,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getR(); + mbResolvingLink = true; + auto ret = mpXLink->getR(); + mbResolvingLink = false; + return ret; } // default is 50% @@ -438,9 +462,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getFx(); + mbResolvingLink = true; + auto ret = mpXLink->getFx(); + mbResolvingLink = false; + return ret; } return nullptr; @@ -455,9 +482,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getFy(); + mbResolvingLink = true; + auto ret = mpXLink->getFy(); + mbResolvingLink = false; + return ret; } return nullptr; @@ -472,9 +502,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); - if(mpXLink) + if (mpXLink && !mbResolvingLink) { - return mpXLink->getGradientTransform(); + mbResolvingLink = true; + auto ret = mpXLink->getGradientTransform(); + mbResolvingLink = false; + return ret; } return nullptr; |