Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

plist_to_xml() returns a string to be freed with xmlFree() rather than free()

#112

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?

Reported by Martin S. · February 10th, 2010 @ 05:55 PM

State: resolved
Milestone: none
Assigned to: Jonathan Beck Jonathan Beck

Activity

  1. teuf
    teuf

    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.

    February 12th, 2010 @ 10:01 AM

  2. Jonathan Beck
    Jonathan Beck
    • 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 ?

    February 12th, 2010 @ 10:11 AM

  3. Jonathan Beck
    Jonathan Beck
    • State changed from open to resolved

    I went with the buffer copy in the end, so it doesn't change the API.

    March 3rd, 2010 @ 05:36 PM

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.