[gxml/gxml-0.20] XDocument: Fix memory leak



commit a5f2279555169c054a9849ba63b5b7dbe28ab2c6
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Mar 16 21:28:02 2021 -0600

    XDocument: Fix memory leak

 gxml/XDocument.vala | 7 +++++++
 gxml/XNode.vala     | 3 +--
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gxml/XDocument.vala b/gxml/XDocument.vala
index a7d193a9..89c04230 100644
--- a/gxml/XDocument.vala
+++ b/gxml/XDocument.vala
@@ -41,6 +41,10 @@ public class GXml.XDocument : GXml.XNode,
   protected Xml.Buffer _buffer;
   protected Parser _parser = null;
 
+  ~XDocument () {
+      delete doc;
+  }
+
   public XDocument () {
     doc = new Xml.Doc ();
   }
@@ -68,6 +72,9 @@ public class GXml.XDocument : GXml.XNode,
     var parser = new XdParser (this);
     parser.read_stream (istream);
   }
+  /**
+   * Gigen {@link Xml.Doc} is owned by this
+   */
   public XDocument.from_doc (Xml.Doc doc) { this.doc = doc; }
 
   public Parser GXml.DomDocument.get_xml_parser () {
diff --git a/gxml/XNode.vala b/gxml/XNode.vala
index 4f1cae14..38a2654a 100644
--- a/gxml/XNode.vala
+++ b/gxml/XNode.vala
@@ -111,7 +111,7 @@ public abstract class GXml.XNode : GLib.Object,
       case GXml.NodeType.COMMENT:
         return new XComment (doc, node);
       case GXml.NodeType.DOCUMENT:
-        return new XDocument.from_doc (node->doc);
+        return doc;
       case GXml.NodeType.DOCUMENT_TYPE:
         return nullnode;
       case GXml.NodeType.DOCUMENT_FRAGMENT:
@@ -197,7 +197,6 @@ public abstract class GXml.XNode : GLib.Object,
            if (this is GXml.DomProcessingInstruction) return this.@value;
            if (this is GXml.DomComment) return this.@value;
            if (this is GXml.DomDocument || this is GXml.DomElement) {
-             message ("Is Element");
              foreach (GXml.DomNode n in children_nodes) {
           if (n is GXml.DomText) {
             if (t == null) t = ((XNode) n).value;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]