From 4f03dbd37c67925b93b5707e3e495471b16ad7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 19 Oct 2022 13:33:39 +0300 Subject: [PATCH] elementfactory: Handle element factory loading failure in gst_element_factory_create_valist() not as assertion In gst_element_factory_create_with_properties() it is a normal error path so let's keep this consistent. Part-of: --- subprojects/gstreamer/gst/gstelementfactory.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/subprojects/gstreamer/gst/gstelementfactory.c b/subprojects/gstreamer/gst/gstelementfactory.c index b74a73b3a7..b94b576aa7 100644 --- a/subprojects/gstreamer/gst/gstelementfactory.c +++ b/subprojects/gstreamer/gst/gstelementfactory.c @@ -573,11 +573,14 @@ gst_element_factory_create_valist (GstElementFactory * factory, GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory))); - g_return_val_if_fail (newfactory != NULL, NULL); - g_return_val_if_fail (newfactory->type != G_TYPE_INVALID, NULL); + if (newfactory == NULL) + goto load_failed; factory = newfactory; + if (factory->type == G_TYPE_INVALID) + goto no_type; + if (!first) { element = gst_element_factory_create_with_properties (factory, 0, NULL, NULL); @@ -602,6 +605,19 @@ gst_element_factory_create_valist (GstElementFactory * factory, out: gst_object_unref (factory); return element; + + /* ERRORS */ +load_failed: + { + GST_WARNING_OBJECT (factory, "loading plugin returned NULL!"); + return NULL; + } +no_type: + { + GST_WARNING_OBJECT (factory, "factory has no type"); + gst_object_unref (factory); + return NULL; + } } /**