[gxml: 17/18] Element.vala: fix issue with freeing xmlAttr memory; don't be overzealous, only free when we'd lose
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml: 17/18] Element.vala: fix issue with freeing xmlAttr memory; don't be overzealous, only free when we'd lose
- Date: Tue, 18 Jun 2013 18:15:23 +0000 (UTC)
commit 15bf4f1f8deffb4756db251905905a9b776cdfbe
Author: Richard Schwarting <aquarichy gmail com>
Date: Mon Jun 10 00:16:21 2013 -0400
Element.vala: fix issue with freeing xmlAttr memory; don't be overzealous, only free when we'd lose
out-of-tree references; in-tree will be handled by xmlFreeDoc
gxml/Element.vala | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 0ee8b89..755365d 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -156,9 +156,15 @@ namespace GXml {
saved_attr = this.node->set_prop (propname, attr.node_value);
}
- // Replace the old out-of-tree attr with the newly allocated one in
the tree, that way xmlFreeDoc can clean up correctly
- attr.node->free ();
- attr.node = saved_attr;
+ /* Replace an old out-of-tree attr with the newly
+ * allocated one in the tree, that way xmlFreeDoc can
+ * clean up correctly */
+ if (attr.node->parent == null) {
+ /* If it was in-tree, xmlSetProp should correctly handle the
+ memory when updating the value within its xmlAttr */
+ attr.node->free ();
+ attr.node = saved_attr;
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]