summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-04-05 20:01:14 +0200
committerGravatar Jonathan Beck2010-04-06 18:25:57 +0200
commit774ce25067303111b6ada712339b7d47ad0f87af (patch)
treec9e320ba80925fc33b1c6898d507a86a5717d8c8 /src
parente965b325b5adf4624f74b8d3366dddc2da9f81f3 (diff)
downloadlibplist-774ce25067303111b6ada712339b7d47ad0f87af.tar.gz
libplist-774ce25067303111b6ada712339b7d47ad0f87af.tar.bz2
plist_to_xml: copy terminating 0-byte given from xmlDocDumpMemory
This makes it possible to process the resulting char* directly as a c-string without further copying.
Diffstat (limited to 'src')
-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)
xmlDocDumpMemory(plist_doc, &tmp, &size);
if (size >= 0 && tmp)
{
- *plist_xml = (char*)malloc(size * sizeof(char));
- memcpy(*plist_xml, tmp, size);
+ /* make sure to copy the terminating 0-byte */
+ *plist_xml = (char*)malloc((size+1) * sizeof(char));
+ memcpy(*plist_xml, tmp, size+1);
*length = size;
xmlFree(tmp);
tmp = NULL;