From: Alex Jia <ajia(a)redhat.com>
* Detected by valgrind. Leak introduced in commit 5ab109f.
* python/libvirt-override.c: avoid memory leak on libvirt_virConnectOpenAuth.
* How to reproduce?
% valgrind -v --leak-check=full virt-clone --print-xml
Note: it can hit the issue although options are incomplete.
* Actual valgrind result:
==1801== 12 bytes in 1 blocks are definitely lost in loss record 25 of 3,270
==1801== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==1801== by 0xCF1F60E: libvirt_virConnectOpenAuth (libvirt-override.c:1507)
==1801== by 0x3AFEEDE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==1801== by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801== by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801== by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801== by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801== by 0x3AFEEE0466: PyEval_EvalCodeEx (ceval.c:3044)
==1801== by 0x3AFEEE0541: PyEval_EvalCode (ceval.c:545)
==1801== by 0x3AFEEFB88B: run_mod (pythonrun.c:1351)
==1801== by 0x3AFEEFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==1801== by 0x3AFEEFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
python/libvirt-override.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4aee628..8a643a3 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -1520,6 +1520,7 @@ libvirt_virConnectOpenAuth(PyObject *self ATTRIBUTE_UNUSED, PyObject
*args) {
c_retval = virConnectOpenAuth(name, &auth, flags);
LIBVIRT_END_ALLOW_THREADS;
+ free(auth.credtype);
py_retval = libvirt_virConnectPtrWrap((virConnectPtr) c_retval);
return(py_retval);
}
--
1.7.1