plist_to_xml() returns a string to be freed with xmlFree() rather than free()
Reported by Martin S. | February 10th, 2010 @ 05:55 PM
Title says it all. Some valgrinding revealed plist_to_xml() uses "xmlDocDumpMemory(plist_doc, (xmlChar *) plist_xml, &size);" which in turn uses (xmlChar) and should be freed suing xmlFree(). This issue became evident in libgpod which uses libxml and causes that library to spit out errors or even crash on this.
Not sure what the best way would be to fix this, perhaps the original string should be copied?
Comments and changes to this ticket
-
teuf February 12th, 2010 @ 10:01 AM
libxml2 can be told to use malloc/free/... using xmlMemSetup, but using that wouldn't be so nice if the app wants to use libxml2 on its own.
-
Jonathan Beck February 12th, 2010 @ 10:11 AM
- State changed from new to open
Then the two options left are copying the allocated buffer to a mallocated one (clean but not good for perfromance) or wrap the xmlFree in a new plist_xml_free function (good for performance but adds a new function and break symetry with binary plist).
I don't know which one is the best.
Any advice ? -
Jonathan Beck March 3rd, 2010 @ 05:36 PM
- State changed from open to resolved
I went with the buffer copy in the end, so it doesn't change the API.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A project around supporting the iPhone in Linux.
See http://libimobiledevice.org