summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2010-03-03 18:33:49 +0100
committerGravatar Jonathan Beck2010-03-03 18:33:49 +0100
commit9bccdb305845e31bcbc8c693e909cc5561f3dd03 (patch)
tree88ede3f6687fb92de0b842fae40bb51ad9366d3b /src
parent210ead70ada61e6fe89fba935f8180d9aef67284 (diff)
downloadlibplist-9bccdb305845e31bcbc8c693e909cc5561f3dd03.tar.gz
libplist-9bccdb305845e31bcbc8c693e909cc5561f3dd03.tar.bz2
Copy xml buffer to malloced buffer to prevent free / xmlFree mixing.
Diffstat (limited to 'src')
-rw-r--r--src/xplist.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 8b6a632..f9289b0 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -373,9 +373,16 @@ void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)
node_to_xml(plist, &root);
- xmlDocDumpMemory(plist_doc, (xmlChar **) plist_xml, &size);
- if (size >= 0)
+ xmlChar* tmp = NULL;
+ xmlDocDumpMemory(plist_doc, &tmp, &size);
+ if (size >= 0 && tmp)
+ {
+ *plist_xml = (char*)malloc(size * sizeof(char));
+ memcpy(*plist_xml, tmp, size);
*length = size;
+ xmlFree(tmp);
+ tmp = NULL;
+ }
xmlFreeDoc(plist_doc);
}