[PATCH 3/3] python: Fix memory leaks on libvirt_virDomainBlockStatsFlags

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

 



From: Alex Jia <ajia@xxxxxxxxxx>

Detected by valgrind. Leaks introuduced in commit f4c331a.

* python/libvirt-override.c: fix memory leaks on libvirt_virDomainBlockStatsFlags.

* actual valgrind result:

==10849== 160 bytes in 5 blocks are definitely lost in loss record 1,525 of 2,083
==10849==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==10849==    by 0x39E1A85EC3: PyObject_Malloc (obmalloc.c:935)
==10849==    by 0x39E1A77831: _PyLong_New (longobject.c:75)
==10849==    by 0x39E1A79EB6: PyLong_FromLongLong (longobject.c:864)
==10849==    by 0xB8FAD08: libvirt_virDomainBlockStatsFlags (libvirt-override.c:160)
==10849==    by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==10849==    by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880)
==10849==    by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044)
==10849==    by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545)
==10849==    by 0x39E1AFB88B: run_mod (pythonrun.c:1351)
==10849==    by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==10849==    by 0x39E1AFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
==10849==
==10849== 258 bytes in 5 blocks are definitely lost in loss record 1,590 of 2,083
==10849==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==10849==    by 0x39E1A85EC3: PyObject_Malloc (obmalloc.c:935)
==10849==    by 0x39E1A9053C: PyString_FromString (stringobject.c:138)
==10849==    by 0xB8FAD1C: libvirt_virDomainBlockStatsFlags (libvirt-override.c:177)
==10849==    by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==10849==    by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880)
==10849==    by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044)
==10849==    by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545)
==10849==    by 0x39E1AFB88B: run_mod (pythonrun.c:1351)
==10849==    by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==10849==    by 0x39E1AFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
==10849==    by 0x39E1B094CE: Py_Main (main.c:577)

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 python/libvirt-override.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 178745b..a138090 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -176,6 +176,8 @@ libvirt_virDomainBlockStatsFlags(PyObject *self ATTRIBUTE_UNUSED,
 
         key = libvirt_constcharPtrWrap(params[i].field);
         PyDict_SetItem(info, key, val);
+        Py_DECREF(key);
+        Py_DECREF(val);
     }
 
     free(params);
-- 
1.7.1

--
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]