gst/gstpad.override: Fix memory leak for functions that return a newly created buffer...
authorEdward Hervey <bilboed@bilboed.com>
Sat, 6 Dec 2008 15:52:31 +0000 (15:52 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Sat, 6 Dec 2008 15:52:31 +0000 (15:52 +0000)
Original commit message from CVS:
* gst/gstpad.override:
Fix memory leak for functions that return a newly created buffer as
a function argument.
Fixes #554545

ChangeLog
gst/gstpad.override

index 973e6f4..383386c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-12-06  Edward Hervey  <edward.hervey@collabora.co.uk>
 
+       * gst/gstpad.override:
+       Fix memory leak for functions that return a newly created buffer as
+       a function argument.
+       Fixes #554545
+
+2008-12-06  Edward Hervey  <edward.hervey@collabora.co.uk>
+
        * codegen/argtypes.py:
        Add handling of 'keep-refcount' for GBoxed arguments.
        * gst/gst.defs:
index 3ddb665..ec20842 100644 (file)
@@ -942,6 +942,9 @@ _wrap_gst_pad_add_event_probe(PyGObject *self, PyObject *args)
     if (rv)
        GST_PAD_DO_EVENT_SIGNALS (pad)++;
 
+    GST_PAD_DO_BUFFER_SIGNALS (pad)++;
+    GST_DEBUG ("adding event probe to pad %s:%s, now %d probes",
+              GST_DEBUG_PAD_NAME (pad), GST_PAD_DO_BUFFER_SIGNALS (pad));
     GST_OBJECT_UNLOCK (pad);
 
     Py_DECREF(myargs);
@@ -1140,6 +1143,9 @@ _wrap_gst_pad_alloc_buffer (PyGObject *self, PyObject * args, PyObject *kwargs)
         PyList_SetItem(ret, 1, Py_None);
     } else {
         PyList_SetItem(ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buf)));
+       /* Bring down the reference count, since we are meant to be the only
+        * one holding a reference to the newly created buffer. */
+       gst_buffer_unref (buf);
     }
     return ret;
 }
@@ -1170,6 +1176,9 @@ _wrap_gst_pad_alloc_buffer_and_set_caps (PyGObject *self, PyObject * args, PyObj
         PyList_SetItem(ret, 1, Py_None);
     } else {
         PyList_SetItem(ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buf)));
+       /* Bring down the reference count, since we are meant to be the only
+        * one holding a reference to the newly created buffer. */
+       gst_buffer_unref (buf);
     }
     return ret;
 }
@@ -1197,6 +1206,9 @@ _wrap_gst_pad_pull_range (PyGObject *self, PyObject * args, PyObject *kwargs)
         PyList_SetItem(ret, 1, Py_None);
     } else {
         PyList_SetItem(ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buf)));
+       /* Bring down the reference count, since we are meant to be the only
+        * one holding a reference to the newly created buffer. */
+       gst_buffer_unref (buf);
     }
     return ret;
 }
@@ -1224,6 +1236,9 @@ _wrap_gst_pad_get_range (PyGObject *self, PyObject * args, PyObject *kwargs)
         PyList_SetItem(ret, 1, Py_None);
     } else {
         PyList_SetItem(ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buf)));
+       /* Bring down the reference count, since we are meant to be the only
+        * one holding a reference to the newly created buffer. */
+       gst_buffer_unref (buf);
     }
     return ret;
 }