libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
537 stars 304 forks source link

Memory leak in plist_write_to_stream #229

Closed beyonik closed 1 year ago

beyonik commented 1 year ago

plist_write_to_stream uses the plist_to_x series of functions (plist_to_bin, plist_to_xml, plist_to_json, plist_to_openstep) to conveniently support multiple types.

Problem is, these functions place the burden of freeing the allocated buffer on the callee, which plist_write_to_stream does not do, as such this causes a memory leak the size of the plist written to the specific stream.

The fix is quite simple, the output buffer has to be freed after the fwrite call.

nikias commented 1 year ago

Fixed with 2d8d7ef272db06783989f77ba1ed80aa0f4d2dfd. Thanks for reporting!