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

[libvirt] [PATCH 2/3] python: Fix memory leaks on libvirt_virDomainGetMemoryParameters



From: Alex Jia <ajia redhat com>

Detected by valgrind. Leaks introduced in commit 9b38239. 

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

* actual valgrind result:

==2212== 120 bytes in 3 blocks are definitely lost in loss record 1,466 of 2,083
==2212==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2212==    by 0x39E1A85EC3: PyObject_Malloc (obmalloc.c:935)
==2212==    by 0x39E1A77831: _PyLong_New (longobject.c:75)
==2212==    by 0x39E1A79EB6: PyLong_FromLongLong (longobject.c:864)
==2212==    by 0xB8F8D98: libvirt_virDomainGetMemoryParameters (libvirt-override.c:982)
==2212==    by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==2212==    by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880)
==2212==    by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044)
==2212==    by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545)
==2212==    by 0x39E1AFB88B: run_mod (pythonrun.c:1351)
==2212==    by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==2212==    by 0x39E1AFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
==2212==
==2212== 155 bytes in 3 blocks are definitely lost in loss record 1,514 of 2,083
==2212==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2212==    by 0x39E1A85EC3: PyObject_Malloc (obmalloc.c:935)
==2212==    by 0x39E1A9053C: PyString_FromString (stringobject.c:138)
==2212==    by 0xB8F8DAC: libvirt_virDomainGetMemoryParameters (libvirt-override.c:999)
==2212==    by 0x39E1ADE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==2212==    by 0x39E1ADF99E: PyEval_EvalFrameEx (ceval.c:3880)
==2212==    by 0x39E1AE0466: PyEval_EvalCodeEx (ceval.c:3044)
==2212==    by 0x39E1AE0541: PyEval_EvalCode (ceval.c:545)
==2212==    by 0x39E1AFB88B: run_mod (pythonrun.c:1351)
==2212==    by 0x39E1AFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==2212==    by 0x39E1AFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)
==2212==    by 0x39E1B094CE: Py_Main (main.c:577)

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770941

Signed-off-by: Alex Jia <ajia redhat com>
---
	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 fbf325a..178745b 100644
	--- a/python/libvirt-override.c
	+++ b/python/libvirt-override.c
	@@ -998,6 +998,8 @@ libvirt_virDomainGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,

			key = libvirt_constcharPtrWrap(params[i].field);
			PyDict_SetItem(info, key, val);
			+        Py_DECREF(key);
			+        Py_DECREF(val);
			}
			free(params);
			return(info);
			-- 
			1.7.1


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