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

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



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

Attachment: signature.asc
Description: OpenPGP digital signature


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