gsturi: Don't treat invalid format of uri as critical error

Normally uri is get from user input and invalid user input should not
be treated as critical error. Moved gst_uri_is_valid outside of
g_return_val_if_fail.

NULL uri is checked inside of gst_uri_is_valid and is correctly
treated as critical error, removed unneeded checks of NULL uri outside
of gst_uri_is_valid function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/816>
This commit is contained in:
Zhao, Gang 2021-05-09 11:13:48 +08:00 committed by GStreamer Marge Bot
parent add1f17c57
commit ed92fb2430

View file

@ -405,8 +405,8 @@ gst_uri_get_protocol (const gchar * uri)
{
gchar *colon;
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
if (!gst_uri_is_valid (uri))
return NULL;
colon = strstr (uri, ":");
@ -427,9 +427,11 @@ gst_uri_has_protocol (const gchar * uri, const gchar * protocol)
{
gchar *colon;
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (protocol != NULL, FALSE);
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
if (!gst_uri_is_valid (uri)) {
return FALSE;
}
colon = strstr (uri, ":");
@ -460,8 +462,9 @@ gst_uri_get_location (const gchar * uri)
const gchar *colon;
gchar *unescaped = NULL;
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
if (!gst_uri_is_valid (uri)) {
return NULL;
}
colon = strstr (uri, "://");
if (!colon)
@ -632,9 +635,12 @@ gst_element_make_from_uri (const GstURIType type, const gchar * uri,
g_return_val_if_fail (gst_is_initialized (), NULL);
g_return_val_if_fail (GST_URI_TYPE_IS_VALID (type), NULL);
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (!gst_uri_is_valid (uri)) {
return NULL;
}
GST_DEBUG ("type:%d, uri:%s, elementname:%s", type, uri, elementname);
protocol = gst_uri_get_protocol (uri);
@ -796,13 +802,16 @@ gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri,
gchar *protocol;
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), FALSE);
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (iface->set_uri != NULL, FALSE);
if (!gst_uri_is_valid (uri)) {
return FALSE;
}
protocol = gst_uri_get_protocol (uri);
if (iface->get_protocols) {