gsturi: Set GError if uri is invalid
authorZhao, Gang <gang.zhao.42@gmail.com>
Sun, 9 May 2021 03:45:49 +0000 (11:45 +0800)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 26 Jul 2021 11:37:33 +0000 (11:37 +0000)
GError should be set if function call failed and the failed reason is
not a programmer error.

Fixed: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1380
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/816>

gst/gsturi.c

index cd736fb..de61365 100644 (file)
@@ -638,6 +638,8 @@ gst_element_make_from_uri (const GstURIType type, const gchar * uri,
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   if (!gst_uri_is_valid (uri)) {
+    g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+        _("Invalid URI: %s"), uri);
     return NULL;
   }
 
@@ -809,6 +811,8 @@ gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri,
   g_return_val_if_fail (iface->set_uri != NULL, FALSE);
 
   if (!gst_uri_is_valid (uri)) {
+    g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+        _("Invalid URI: %s"), uri);
     return FALSE;
   }