[Libreoffice-commits] core.git: svgio/inc svgio/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 18 13:37:37 UTC 2018


 svgio/inc/svggradientnode.hxx              |    1 
 svgio/source/svgreader/svggradientnode.cxx |   75 ++++++++++++++++++++---------
 2 files changed, 55 insertions(+), 21 deletions(-)

New commits:
commit f35e3b36b0df830d0259d9d754c3da1946da3e6b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 18 12:12:05 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 18 15:37:16 2018 +0200

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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;


More information about the Libreoffice-commits mailing list