Re: [PATCH 2/2] python: add error checking for calls to PyList_New

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

 



On 11/12/2013 06:53 AM, Martin Kletzander wrote:
>> @@ -2621,7 +2630,8 @@ libvirt_virDomainSnapshotListChildrenNames(PyObject *self ATTRIBUTE_UNUSED,
>>              return VIR_PY_NONE;
>>          }
>>      }
>> -    py_retval = PyList_New(c_retval);
>> +    if (!(py_retval = PyList_New(c_retval)))
>> +        goto cleanup;
>>  
> 
> This function should follow others and return VIR_PY_NONE, but cleanup
> path returns py_retval.

Actually, you WANT to return NULL, not VIR_PY_NONE, when PyList_New()
fails.  Returning NULL is the hint to python to report the OOM
exception; returning VIR_PY_NONE is not NULL and therefore silently
papers over the exception.  Worse, the rest of the libvirt python code
treats a return of the python object 'None' as meaning 'the API call
failed, dig out the last virError and turn it into a python exception';
but in this case, there is no virError (our failure was not related to a
failed C API call).  This code rewrite is correct as-is.

-- 
Eric Blake   eblake redhat com    +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]