From 487a3f9a30be15c72a98ca6cd744efb9c3d9a68e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 30 Sep 2019 11:34:51 +0300 Subject: [PATCH] bin: Drop need-context messages without source instead of crashing --- gst/gstbin.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index 4a9423a..173b8bc 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -4010,24 +4010,32 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message) GList *l, *contexts; gst_message_parse_context_type (message, &context_type); - GST_OBJECT_LOCK (bin); - contexts = GST_ELEMENT_CAST (bin)->contexts; - GST_LOG_OBJECT (bin, "got need-context message type: %s", context_type); - for (l = contexts; l; l = l->next) { - GstContext *tmp = l->data; - const gchar *tmp_type = gst_context_get_context_type (tmp); - - if (strcmp (context_type, tmp_type) == 0) { - gst_element_set_context (GST_ELEMENT (src), l->data); - break; + + if (src) { + GST_OBJECT_LOCK (bin); + contexts = GST_ELEMENT_CAST (bin)->contexts; + GST_LOG_OBJECT (bin, "got need-context message type: %s", context_type); + for (l = contexts; l; l = l->next) { + GstContext *tmp = l->data; + const gchar *tmp_type = gst_context_get_context_type (tmp); + + if (strcmp (context_type, tmp_type) == 0) { + gst_element_set_context (GST_ELEMENT (src), l->data); + break; + } } - } - GST_OBJECT_UNLOCK (bin); + GST_OBJECT_UNLOCK (bin); - /* Forward if we couldn't answer the message */ - if (l == NULL) { - goto forward; + /* Forward if we couldn't answer the message */ + if (l == NULL) { + goto forward; + } else { + gst_message_unref (message); + } } else { + g_warning + ("Got need-context message in bin '%s' without source element, dropping", + GST_ELEMENT_NAME (bin)); gst_message_unref (message); } -- 2.7.4