[libvirt] [python PATCH] iothread: Fix crash if virDomainGetIOThreadInfo returns error

The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to clean the returned structures but the count of iothreads was set to -1. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295 --- libvirt-override.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 45c8afc..2398228 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2104,8 +2104,10 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATTRIBUTE_UNUSED, py_iothrinfo = NULL; cleanup: - for (i = 0; i < niothreads; i++) - virDomainIOThreadInfoFree(iothrinfo[i]); + if (niothreads > 0) { + for (i = 0; i < niothreads; i++) + virDomainIOThreadInfoFree(iothrinfo[i]); + } VIR_FREE(iothrinfo); Py_XDECREF(py_iothrinfo); return py_retval; -- 2.4.5

On 30/07/15 09:36, Peter Krempa wrote:
The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to clean the returned structures but the count of iothreads was set to -1.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295 --- libvirt-override.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c index 45c8afc..2398228 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2104,8 +2104,10 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATTRIBUTE_UNUSED, py_iothrinfo = NULL;
cleanup: - for (i = 0; i < niothreads; i++) - virDomainIOThreadInfoFree(iothrinfo[i]); + if (niothreads > 0) { + for (i = 0; i < niothreads; i++) + virDomainIOThreadInfoFree(iothrinfo[i]); + } VIR_FREE(iothrinfo); Py_XDECREF(py_iothrinfo); return py_retval;
ACK Erik

On Thu, Jul 30, 2015 at 09:49:51 +0200, Erik Skultety wrote:
On 30/07/15 09:36, Peter Krempa wrote:
The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to clean the returned structures but the count of iothreads was set to -1.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295 --- libvirt-override.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
...
ACK
Pushed; Thanks. Peter
participants (2)
-
Erik Skultety
-
Peter Krempa