summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/xplist.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/xplist.c b/src/xplist.c
index f9289b0..3e9f043 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -377,8 +377,9 @@ void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)
377 xmlDocDumpMemory(plist_doc, &tmp, &size); 377 xmlDocDumpMemory(plist_doc, &tmp, &size);
378 if (size >= 0 && tmp) 378 if (size >= 0 && tmp)
379 { 379 {
380 *plist_xml = (char*)malloc(size * sizeof(char)); 380 /* make sure to copy the terminating 0-byte */
381 memcpy(*plist_xml, tmp, size); 381 *plist_xml = (char*)malloc((size+1) * sizeof(char));
382 memcpy(*plist_xml, tmp, size+1);
382 *length = size; 383 *length = size;
383 xmlFree(tmp); 384 xmlFree(tmp);
384 tmp = NULL; 385 tmp = NULL;