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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]