diff options
| author | 2010-03-03 18:33:49 +0100 | |
|---|---|---|
| committer | 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) | |||
| 373 | 373 | ||
| 374 | node_to_xml(plist, &root); | 374 | node_to_xml(plist, &root); |
| 375 | 375 | ||
| 376 | xmlDocDumpMemory(plist_doc, (xmlChar **) plist_xml, &size); | 376 | xmlChar* tmp = NULL; |
| 377 | if (size >= 0) | 377 | xmlDocDumpMemory(plist_doc, &tmp, &size); |
| 378 | if (size >= 0 && tmp) | ||
| 379 | { | ||
| 380 | *plist_xml = (char*)malloc(size * sizeof(char)); | ||
| 381 | memcpy(*plist_xml, tmp, size); | ||
| 378 | *length = size; | 382 | *length = size; |
| 383 | xmlFree(tmp); | ||
| 384 | tmp = NULL; | ||
| 385 | } | ||
| 379 | xmlFreeDoc(plist_doc); | 386 | xmlFreeDoc(plist_doc); |
| 380 | } | 387 | } |
| 381 | 388 | ||
