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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 23 20:18:01 UTC 2018


 svgio/inc/svgpatternnode.hxx              |    1 
 svgio/source/svgreader/svgpatternnode.cxx |   71 +++++++++++++++++++++---------
 2 files changed, 52 insertions(+), 20 deletions(-)

New commits:
commit 2a1e975f4fa67162f3c7b37939fa0a3b771376f5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jul 23 16:10:08 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jul 23 22:17:40 2018 +0200

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

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;


More information about the Libreoffice-commits mailing list