mpegtsmux: Fix memory leak when using prepare_func
authorGreg Rutz <greg@gsr-tek.com>
Tue, 7 May 2013 14:26:03 +0000 (08:26 -0600)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 7 May 2013 14:37:49 +0000 (16:37 +0200)
prepare_func will allocate a new buffer to replace the original
one. Instead of using gst_buffer_replace (which causes an extra
refcount increment on the new buffer), we just unref the original
buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=699786

gst/mpegtsmux/mpegtsmux.c

index 78e7cbd..ed5f988 100644 (file)
@@ -1018,9 +1018,9 @@ mpegtsmux_clip_inc_running_time (GstCollectPads * pads,
   if (pad_data->prepare_func) {
     MpegTsMux *mux = (MpegTsMux *) user_data;
 
-    buf = pad_data->prepare_func (buf, pad_data, mux);
-    if (buf)
-      gst_buffer_replace (outbuf, buf);
+    *outbuf = pad_data->prepare_func (buf, pad_data, mux);
+    g_assert (*outbuf);
+    gst_buffer_unref (buf);
   }
 
   return GST_FLOW_OK;