From 6a38f51266829feb975cdd8daed6656842e5ecd9 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 18 May 2014 02:39:13 +0200 Subject: bplist: Fix memory leaking caused by unused nodes in plist_from_bin() --- src/bplist.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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); } -- cgit v1.1-32-gdbae