Commit 774ce250 authored by Nikias Bassen's avatar Nikias Bassen Committed by Jonathan Beck

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.
parent e965b325
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment