WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-3.4-testing] xend: Fix memory leaks in libxc python

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.4-testing] xend: Fix memory leaks in libxc python bindings
From: "Xen patchbot-3.4-testing" <patchbot-3.4-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 01 Oct 2009 08:25:31 -0700
Delivery-date: Thu, 01 Oct 2009 08:27:05 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1254410147 -3600
# Node ID d234358df883240ad93598b16b8ca4c3198a0a54
# Parent  d1725e7a66b2fa42d8a502e9d0d876afeb5bbaf8
xend: Fix memory leaks in libxc python bindings

Reference counters are not correctly decreased for python object in
several places in python bindings for libxc. Most of them are around
PyList_Append(), which unlike PyList_SetItem() does increment
reference counter of the object being added to a list.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
xen-unstable changeset:   20263:516d7de8e9a1
xen-unstable date:        Wed Sep 30 08:44:57 2009 +0100
---
 tools/python/xen/lowlevel/xc/xc.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff -r d1725e7a66b2 -r d234358df883 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Thu Oct 01 16:15:12 2009 +0100
+++ b/tools/python/xen/lowlevel/xc/xc.c Thu Oct 01 16:15:47 2009 +0100
@@ -386,8 +386,11 @@ static PyObject *pyxc_vcpu_getinfo(XcObj
     cpulist = PyList_New(0);
     for ( i = 0; cpumap != 0; i++ )
     {
-        if ( cpumap & 1 )
-            PyList_Append(cpulist, PyInt_FromLong(i));
+        if ( cpumap & 1 ) {
+            PyObject *pyint = PyInt_FromLong(i);
+            PyList_Append(cpulist, pyint);
+            Py_DECREF(pyint);
+        }
         cpumap >>= 1;
     }
     PyDict_SetItemString(info_dict, "cpumap", cpulist);
@@ -1100,22 +1103,31 @@ static PyObject *pyxc_physinfo(XcObject 
     {
         PyObject *cpus = PyList_New(0);
         for ( j = 0; j <= max_cpu_id; j++ )
-            if ( i == map[j])
-                PyList_Append(cpus, PyInt_FromLong(j));
+            if ( i == map[j]) {
+                PyObject *pyint = PyInt_FromLong(j);
+                PyList_Append(cpus, pyint);
+                Py_DECREF(pyint);
+            }
         PyList_Append(node_to_cpu_obj, cpus); 
+        Py_DECREF(cpus);
     }
 
     node_to_memory_obj = PyList_New(0);
 
     for ( i = 0; i < info.nr_nodes; i++ )
     {
+        PyObject *pyint;
+
         xc_availheap(self->xc_handle, 0, 0, i, &free_heap);
-        PyList_Append(node_to_memory_obj,
-                      PyInt_FromLong(free_heap / 1024));
+        pyint = PyInt_FromLong(free_heap / 1024);
+        PyList_Append(node_to_memory_obj, pyint);
+        Py_DECREF(pyint);
     }
 
     PyDict_SetItemString(ret_obj, "node_to_cpu", node_to_cpu_obj);
+    Py_DECREF(node_to_cpu_obj);
     PyDict_SetItemString(ret_obj, "node_to_memory", node_to_memory_obj);
+    Py_DECREF(node_to_memory_obj);
  
     return ret_obj;
 #undef MAX_CPU_ID

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.4-testing] xend: Fix memory leaks in libxc python bindings, Xen patchbot-3.4-testing <=