diff options
author | Jonathan Beck | 2010-03-03 18:33:49 +0100 |
---|---|---|
committer | Jonathan Beck | 2010-03-03 18:33:49 +0100 |
commit | 9bccdb305845e31bcbc8c693e909cc5561f3dd03 (patch) | |
tree | 88ede3f6687fb92de0b842fae40bb51ad9366d3b | |
parent | 210ead70ada61e6fe89fba935f8180d9aef67284 (diff) | |
download | libplist-9bccdb305845e31bcbc8c693e909cc5561f3dd03.tar.gz libplist-9bccdb305845e31bcbc8c693e909cc5561f3dd03.tar.bz2 |
Copy xml buffer to malloced buffer to prevent free / xmlFree mixing.
-rw-r--r-- | src/xplist.c | 11 |
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); } |