summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2014-07-24 15:28:09 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2014-07-31 09:15:29 -0400
commitc2dbd182205618de254b65857cf2678bd677be76 (patch)
treea1d835be103038f01c794d6f9fe1ad272e6d92c5
parent9cd4b27c4d4331a734351713f3febf8a5d9687ac (diff)
ximagesrc: Add missing return value to Buffer dispose function
Depending ont he build, the method could return FALSE, hence never free the buffers, or already TRUE and lead to a crash: Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=733695
-rw-r--r--sys/ximage/gstximagesrc.c7
-rw-r--r--sys/ximage/ximageutil.c7
-rw-r--r--sys/ximage/ximageutil.h2
3 files changed, 11 insertions, 5 deletions
diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c
index 17f4a4e971..8058a953b6 100644
--- a/sys/ximage/gstximagesrc.c
+++ b/sys/ximage/gstximagesrc.c
@@ -85,10 +85,12 @@ static GstCaps *gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
static void gst_ximage_src_clear_bufpool (GstXImageSrc * ximagesrc);
/* Called when a buffer is returned from the pipeline */
-static void
+static gboolean
gst_ximage_src_return_buf (GstXImageSrc * ximagesrc, GstBuffer * ximage)
{
GstMetaXImage *meta = GST_META_XIMAGE_GET (ximage);
+ /* True will make dispose free the buffer, while false will keep it */
+ gboolean ret = TRUE;
/* If our geometry changed we can't reuse that image. */
if ((meta->width != ximagesrc->width) || (meta->height != ximagesrc->height)) {
@@ -107,7 +109,10 @@ gst_ximage_src_return_buf (GstXImageSrc * ximagesrc, GstBuffer * ximage)
GST_BUFFER_FLAGS (GST_BUFFER (ximage)) = 0; /* clear out any flags from the previous use */
ximagesrc->buffer_pool = g_slist_prepend (ximagesrc->buffer_pool, ximage);
g_mutex_unlock (&ximagesrc->pool_lock);
+ ret = FALSE;
}
+
+ return ret;
}
static Window
diff --git a/sys/ximage/ximageutil.c b/sys/ximage/ximageutil.c
index 76d2866ac0..a96a515b7a 100644
--- a/sys/ximage/ximageutil.c
+++ b/sys/ximage/ximageutil.c
@@ -314,11 +314,12 @@ ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext)
GST_DEBUG ("set xcontext PAR to %d/%d\n", xcontext->par_n, xcontext->par_d);
}
-static void
+static gboolean
gst_ximagesrc_buffer_dispose (GstBuffer * ximage)
{
GstElement *parent;
GstMetaXImage *meta;
+ gboolean ret = TRUE;
g_return_if_fail (ximage != NULL);
@@ -331,10 +332,10 @@ gst_ximagesrc_buffer_dispose (GstBuffer * ximage)
}
if (meta->return_func)
- meta->return_func (parent, ximage);
+ ret = meta->return_func (parent, ximage);
beach:
- return;
+ return ret;
}
void
diff --git a/sys/ximage/ximageutil.h b/sys/ximage/ximageutil.h
index d5e88fac8e..cd2e8893ea 100644
--- a/sys/ximage/ximageutil.h
+++ b/sys/ximage/ximageutil.h
@@ -134,7 +134,7 @@ void ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext);
/* custom ximagesrc buffer, copied from ximagesink */
/* BufferReturnFunc is called when a buffer is finalised */
-typedef void (*BufferReturnFunc) (GstElement *parent, GstBuffer *buf);
+typedef gboolean (*BufferReturnFunc) (GstElement *parent, GstBuffer *buf);
/**
* GstMetaXImage: