On Fri, Sep 07, 2007 at 12:18:05PM -0400, beth kon wrote:
Hi. Seems to me there is a memory leak with the strdup function in
xenHypervisorMakeCapabilitiesXML. Looking up the chain of calls leading
to xenHypervisorMakeCapabilitiesXML, I don't see the required free for
the hidden malloc in the strdup. The same problem may exist with other
strdups in the code.
I assume you're referring to this snippet of code at the end of the
xenHypervisorMakeCapabilitiesXML function:
xml_str = strdup (xml->content);
if (!xml_str) goto vir_buffer_failed;
virBufferFree (xml);
return xml_str;
This 'xml_str' get propagated back to the caller, in this case the caller
is xenHypervisorGetCapabilities. This method is in turn called from the
public API virConnectGetCapabilities. To the xml_str buffer is returned
to teh caller of the public API. The contract of this API says:
* The client must free the returned string after use.
So the memory from the strdup is required to be free'd by whomever calls
the virConnectGetCapabilities() API.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules:
http://search.cpan.org/~danberr/ -=|
|=- Projects:
http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|