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.
---
python/libvirt-override.c | 56 +++++++++++++++++++++++++++++++--------------
1 file changed, 39 insertions(+), 17 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index da5cb9a..676002c 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2045,7 +2048,7 @@ libvirt_virDomainSnapshotListNames(PyObject
*self ATTRIBUTE_UNUSED,
if (c_retval) {
if (VIR_ALLOC_N(names, c_retval) < 0)
- return VIR_PY_NONE;
+ return PyErr_NoMemory();
I'll have to tweak my domain list python bindings to use this func too.
LIBVIRT_BEGIN_ALLOW_THREADS;
c_retval = virDomainSnapshotListNames(dom, names, c_retval, flags);
LIBVIRT_END_ALLOW_THREADS;
+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.
return py_retval;
}
ACK.
Peter