Public bug reported:

if didn't unref after pygobject_new.

while(1):
      a=pango_cairo.create_layout()

may cause, memory run out: python doesn't GC this memory.

The patch is:

Index: pygtk-2.24.0/pangocairo.override
===================================================================
--- pygtk-2.24.0.orig/pangocairo.override    2012-04-14 01:40:59.568703232
+0800
+++ pygtk-2.24.0/pangocairo.override    2012-04-14 01:41:05.792703324 +0800
@@ -119,10 +119,15 @@
 _wrap_pango_cairo_create_layout(PyGObject *self)
 {
     PangoLayout *ret;
+    PyObject *py_ret;

     ret = pango_cairo_create_layout(PycairoContext_GET(self));
     /* pygobject_new handles NULL checking */
-    return pygobject_new((GObject *)ret);
+    py_ret = pygobject_new((GObject *) ret);
+    if (ret) {
+    g_object_unref(ret);
+    }
+    return py_ret;
 }

 static PyObject *

** Affects: pygtk
     Importance: Unknown
         Status: Unknown

** Affects: pygtk (Ubuntu)
     Importance: Undecided
         Status: New

** Bug watch added: GNOME Bug Tracker #674092
   https://bugzilla.gnome.org/show_bug.cgi?id=674092

** Also affects: pygtk via
   https://bugzilla.gnome.org/show_bug.cgi?id=674092
   Importance: Unknown
       Status: Unknown

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to pygtk in Ubuntu.
https://bugs.launchpad.net/bugs/981376

Title:
  [Patch] memory leak in _wrap_pango_cairo_create_layout

Status in PyGTK: GTK+ for Python:
  Unknown
Status in “pygtk” package in Ubuntu:
  New

Bug description:
  if didn't unref after pygobject_new.

  while(1):
        a=pango_cairo.create_layout()

  may cause, memory run out: python doesn't GC this memory.

  The patch is:

  Index: pygtk-2.24.0/pangocairo.override
  ===================================================================
  --- pygtk-2.24.0.orig/pangocairo.override    2012-04-14 01:40:59.568703232
  +0800
  +++ pygtk-2.24.0/pangocairo.override    2012-04-14 01:41:05.792703324 +0800
  @@ -119,10 +119,15 @@
   _wrap_pango_cairo_create_layout(PyGObject *self)
   {
       PangoLayout *ret;
  +    PyObject *py_ret;

       ret = pango_cairo_create_layout(PycairoContext_GET(self));
       /* pygobject_new handles NULL checking */
  -    return pygobject_new((GObject *)ret);
  +    py_ret = pygobject_new((GObject *) ret);
  +    if (ret) {
  +    g_object_unref(ret);
  +    }
  +    return py_ret;
   }

   static PyObject *

To manage notifications about this bug go to:
https://bugs.launchpad.net/pygtk/+bug/981376/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : desktop-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to