summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2015-12-07 16:16:40 +0100
committerGravatar Nikias Bassen2015-12-07 16:16:40 +0100
commit060eda6b1846968aa40b0d38dcf92ac46f933417 (patch)
tree5c36a7ef0da97480813382921e86a79ed98376a5 /src
parent9834d85ca473ef9b229dcf4c0df758e18a4149ad (diff)
downloadlibplist-060eda6b1846968aa40b0d38dcf92ac46f933417.tar.gz
libplist-060eda6b1846968aa40b0d38dcf92ac46f933417.tar.bz2
Node.cpp: let plist_t operations free _node when in a container.
Fixes libimobiledevice/libplist#50.
Diffstat (limited to 'src')
-rw-r--r--src/Node.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Node.cpp b/src/Node.cpp
index aaadd52..3da401e 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -88,7 +88,12 @@ Node::Node(plist_type type, Node* parent) : _parent(parent)
Node::~Node()
{
- plist_free(_node);
+ /* If the Node is in a container, let _node be cleaned up by
+ * operations on the parent plist_t. Otherwise, duplicate frees
+ * occur when a Node is removed from or replaced in a Dictionary.
+ */
+ if (_parent == NULL)
+ plist_free(_node);
_node = NULL;
_parent = NULL;
}