From 339df347a0eb8098335c86e4138f012974140b7c Mon Sep 17 00:00:00 2001 From: Stian Selnes Date: Tue, 29 Mar 2011 11:57:06 +0200 Subject: [PATCH] gstqueue, gstqueue2: check if parent of pad is NULL in _getcaps Parent of the pad (the queue) may be set to NULL while there is a buffer alloc going on. --- plugins/elements/gstqueue.c | 6 +++++- plugins/elements/gstqueue2.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index a641dfe..6a21a3e 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -487,13 +487,17 @@ gst_queue_getcaps (GstPad * pad) GstPad *otherpad; GstCaps *result; - queue = GST_QUEUE (GST_PAD_PARENT (pad)); + queue = GST_QUEUE (gst_pad_get_parent (pad)); + if (G_UNLIKELY (queue == NULL)) + return gst_caps_new_any (); otherpad = (pad == queue->srcpad ? queue->sinkpad : queue->srcpad); result = gst_pad_peer_get_caps (otherpad); if (result == NULL) result = gst_caps_new_any (); + gst_object_unref (queue); + return result; } diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index adc304a..08ce4cb 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -648,13 +648,17 @@ gst_queue2_getcaps (GstPad * pad) GstPad *otherpad; GstCaps *result; - queue = GST_QUEUE2 (GST_PAD_PARENT (pad)); + queue = GST_QUEUE2 (gst_pad_get_parent (pad)); + if (G_UNLIKELY (queue == NULL)) + return gst_caps_new_any (); otherpad = (pad == queue->srcpad ? queue->sinkpad : queue->srcpad); result = gst_pad_peer_get_caps (otherpad); if (result == NULL) result = gst_caps_new_any (); + gst_object_unref (queue); + return result; } -- 2.7.4