summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-05-18 02:39:13 +0200
committerGravatar Nikias Bassen2014-05-18 02:39:13 +0200
commit6a38f51266829feb975cdd8daed6656842e5ecd9 (patch)
tree1b0112f0b52efca31128310abdfc3bf2a76b3a43
parentdf053ccdbb1cec856aa3a99c836ec6111d727a78 (diff)
downloadlibplist-6a38f51266829feb975cdd8daed6656842e5ecd9.tar.gz
libplist-6a38f51266829feb975cdd8daed6656842e5ecd9.tar.bz2
bplist: Fix memory leaking caused by unused nodes in plist_from_bin()
-rw-r--r--src/bplist.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 523d0fe..d1694b9 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -715,6 +715,15 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
}
*plist = nodeslist[root_object];
+
+ // free unreferenced nodes that would otherwise leak memory
+ for (i = 0; i < num_objects; i++) {
+ if (i == root_object) continue;
+ node_t* node = (node_t*)nodeslist[i];
+ if (NODE_IS_ROOT(node)) {
+ plist_free(node);
+ }
+ }
free(nodeslist);
}