svgio/inc/svgdocument.hxx          |    6 ++++++
 svgio/source/svgreader/svgnode.cxx |    9 ++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 0dfd8288a87b58e503bb3a41be6137485fbf3f68
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Jul 5 09:31:58 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Jul 5 15:08:05 2023 +0200

    ofz#60384 Direct-leak
    
    since:
    
    commit 13a41e7a12598c7896d6dc8d34aba6af5b80b83c
    Date:   Mon Jul 3 14:11:43 2023 +0200
    
        tdf#150124: do nothing when parent is of unkown type
    
    Change-Id: I58edf5f63d97e8afb1cd58c7e23452a9ea6a87eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154023
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/svgio/inc/svgdocument.hxx b/svgio/inc/svgdocument.hxx
index 9f79342c0c55..77b4d3891179 100644
--- a/svgio/inc/svgdocument.hxx
+++ b/svgio/inc/svgdocument.hxx
@@ -34,6 +34,9 @@ namespace svgio::svgreader
             /// the document hierarchy with all root nodes
             SvgNodeVector           maNodes;
 
+            /// invalid nodes that have no parent
+            SvgNodeVector           maOrphanNodes;
+
             /// the absolute path of the Svg file in progress (if available)
             const OUString     maAbsolutePath;
 
@@ -72,6 +75,9 @@ namespace svgio::svgreader
             /// data read access
             const SvgNodeVector& getSvgNodeVector() const { return maNodes; }
             const OUString& getAbsolutePath() const { return maAbsolutePath; }
+
+            /// invalid nodes that have no parent
+            void addOrphanNode(SvgNode* pOrphan) { 
maOrphanNodes.emplace_back(pOrphan); }
         };
 
 } // end of namespace svgio::svgreader
diff --git a/svgio/source/svgreader/svgnode.cxx 
b/svgio/source/svgreader/svgnode.cxx
index d87c76d81e20..992aaf72bce0 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -395,10 +395,13 @@ namespace {
             mbDecomposing(false),
             mbCssStyleVectorBuilt(false)
         {
-            // tdf#150124 ignore when parent is unknown
-            if(pParent && pParent->getType() != SVGToken::Unknown)
+            if (pParent)
             {
-                pParent->maChildren.emplace_back(this);
+                // tdf#150124 ignore when parent is unknown
+                if (pParent->getType() != SVGToken::Unknown)
+                    pParent->maChildren.emplace_back(this);
+                else
+                    mrDocument.addOrphanNode(this);
             }
         }
 

Reply via email to