[libvirt] [PATCH 2/2] python: fix snapshot listing bugs

Eric Blake eblake at redhat.com
Tue Jun 12 12:46:24 UTC 2012


On 06/12/2012 03:12 AM, Peter Krempa wrote:
> On 06/11/12 22:52, Eric Blake wrote:
>> Python exceptions are different than libvirt errors, and we had
>> some corner case bugs on OOM situations.
>>
>> * python/libvirt-override.c (libvirt_virDomainSnapshotListNames)
>> (libvirt_virDomainSnapshotListChildrenNames): Use correct error
>> returns, avoid segv on OOM, and avoid memory leaks on error.

>> +cleanup:
>> +    for (i = 0; i < c_retval; i++)
>> +        VIR_FREE(names[i]);
>> +    VIR_FREE(names);
> 
> Probably not worth optimizing this not to iterate the array on success.

The old code had one iteration through the array, but if it failed
halfway through, leaked the other half of the array.  The new code
separates the iterations on purpose, so that the cleanup happens
regardless of success or failure.

> 
>>       return py_retval;
>>   }
>>
> 
> 
> ACK.

Thanks; series pushed.

-- 
Eric Blake   eblake at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120612/78166a6e/attachment-0001.sig>


More information about the libvir-list mailing list