[libvirt] [PATCH v2] storage: Avoid memory leak on metadata fetching

Eric Blake eblake at redhat.com
Thu Jul 14 12:29:08 UTC 2011


On 07/14/2011 06:23 AM, Jiri Denemark wrote:
>> +void ATTRIBUTE_NONNULL(1)
>> +virStorageFileFreeMetadata(virStorageFileMetadata *meta)
>> +{
>> +    VIR_FREE(meta->backingStore);
>> +    VIR_FREE(meta);
>> +}
> 
> We like having free-like functions to work with NULL arguments, shouldn't we
> follow that habit here as well?

Yes - add:

if (!meta)
    return;

here, and update cfg.mk to list virStorageFileFreeMetadata in the list
of free-like functions.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110714/b9f5f77e/attachment-0001.sig>


More information about the libvir-list mailing list