[libvirt] [PATCH 1/5] conf: avoid memleak on NULL path
Eric Blake
eblake at redhat.com
Mon Apr 7 22:33:14 UTC 2014
On 04/07/2014 02:22 AM, Peter Krempa wrote:
> On 04/06/14 05:32, Eric Blake wrote:
>> I noticed that the apparmor code could request metadata even
>> for a cdrom with no media, which would cause a memory leak of
>> the hash table used to look for loops in the backing chain.
>> But even before that, we blindly dereferenced the path for
>> printing a debug statement, so it is just better to enforce
>> that this is only used on non-NULL names.
>>
>> +++ b/src/util/virstoragefile.c
>> @@ -1142,9 +1142,9 @@ virStorageFileGetMetadata(const char *path, int format,
>> path, format, (int)uid, (int)gid, allow_probe);
>>
>> virHashTablePtr cycle = virHashCreate(5, NULL);
>> - virStorageFileMetadataPtr ret;
>> + virStorageFileMetadataPtr ret = NULL;
>
> This assignment will always be overwritten or unused.
Leftovers from a different approach I had tried. I dropped this change...
>
>>
>> - if (!cycle || !path)
>> + if (!cycle)
>> return NULL;
>>
>> if (format <= VIR_STORAGE_FILE_NONE)
>
> ACK,
and pushed.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140407/ea2e4243/attachment-0001.sig>
More information about the libvir-list
mailing list