diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index e9e79f4f17..2594f04872 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -1304,17 +1304,24 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event) static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query) { - GstQueue *queue = GST_QUEUE (GST_PAD_PARENT (pad)); + GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad)); GstPad *peer; gboolean res; - if (!(peer = gst_pad_get_peer (queue->sinkpad))) + if (G_UNLIKELY (queue == NULL)) return FALSE; + if (!(peer = gst_pad_get_peer (queue->sinkpad))) { + gst_object_unref (queue); + return FALSE; + } + res = gst_pad_query (peer, query); gst_object_unref (peer); - if (!res) + if (!res) { + gst_object_unref (queue); return FALSE; + } switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: @@ -1370,6 +1377,7 @@ gst_queue_handle_src_query (GstPad * pad, GstQuery * query) break; } + gst_object_unref (queue); return TRUE; } diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 0a2b28c0dd..431c131609 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -2441,7 +2441,9 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) { GstQueue2 *queue; - queue = GST_QUEUE2 (GST_PAD_PARENT (pad)); + queue = GST_QUEUE2 (gst_pad_get_parent (pad)); + if (G_UNLIKELY (queue == NULL)) + return FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: @@ -2612,12 +2614,14 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) break; } + gst_object_unref (queue); return TRUE; /* ERRORS */ peer_failed: { GST_DEBUG_OBJECT (queue, "failed peer query"); + gst_object_unref (queue); return FALSE; } }