[Libreoffice-commits] core.git: Branch 'libreoffice-6-1-0' - svgio/inc svgio/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 2 11:49:12 UTC 2018


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

New commits:
commit a662ec944f32fb94789d3d7f84d6c6192b82777e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jul 23 16:10:08 2018 +0100
Commit:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Thu Aug 2 13:48:48 2018 +0200

    crashtesting: infinite recurse with moz455984-5.svg
    
    Change-Id: Idef368c44454ae144b091132cd0d6103f92a6dde
    Reviewed-on: https://gerrit.libreoffice.org/57856
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.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