From 6971993051ba16c374d7385e7ab65fa7f3b57e0c Mon Sep 17 00:00:00 2001
Message-Id: <6971993051ba16c374d7385e7ab65fa7f3b57e0c@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 30 Jul 2015 10:04:02 +0200
Subject: [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
(cherry picked from commit 0a59630a341f73f716e635a8635c053861695cf1)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
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.5.0