From 498ad133bada157055b281fed99b3f622fdfc8fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 26 Sep 2022 14:17:18 +0300 Subject: [PATCH] gsturi: When setting the same string again do nothing Otherwise code like gst_uri_set_host(uri, gst_uri_get_host(uri)) would first free the string, then create a copy of the freed string and then assigned that. Part-of: --- subprojects/gstreamer/gst/gsturi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/subprojects/gstreamer/gst/gsturi.c b/subprojects/gstreamer/gst/gsturi.c index 8d52423..47d6a53 100644 --- a/subprojects/gstreamer/gst/gsturi.c +++ b/subprojects/gstreamer/gst/gsturi.c @@ -2166,6 +2166,9 @@ gst_uri_set_scheme (GstUri * uri, const gchar * scheme) return scheme == NULL; g_return_val_if_fail (GST_IS_URI (uri) && gst_uri_is_writable (uri), FALSE); + if (uri->scheme == scheme) + return TRUE; + g_free (uri->scheme); uri->scheme = g_strdup (scheme); @@ -2208,6 +2211,8 @@ gst_uri_set_userinfo (GstUri * uri, const gchar * userinfo) return userinfo == NULL; g_return_val_if_fail (GST_IS_URI (uri) && gst_uri_is_writable (uri), FALSE); + if (uri->userinfo == userinfo) + return TRUE; g_free (uri->userinfo); uri->userinfo = g_strdup (userinfo); @@ -2250,6 +2255,9 @@ gst_uri_set_host (GstUri * uri, const gchar * host) return host == NULL; g_return_val_if_fail (GST_IS_URI (uri) && gst_uri_is_writable (uri), FALSE); + if (uri->host == host) + return TRUE; + g_free (uri->host); uri->host = g_strdup (host); @@ -2669,6 +2677,9 @@ gst_uri_set_query_table (GstUri * uri, GHashTable * query_table) return query_table == NULL; g_return_val_if_fail (GST_IS_URI (uri) && gst_uri_is_writable (uri), FALSE); + if (uri->query == query_table) + return TRUE; + old_table = uri->query; if (query_table) uri->query = g_hash_table_ref (query_table); @@ -2853,6 +2864,9 @@ gst_uri_set_fragment (GstUri * uri, const gchar * fragment) return fragment == NULL; g_return_val_if_fail (GST_IS_URI (uri) && gst_uri_is_writable (uri), FALSE); + if (uri->fragment == fragment) + return TRUE; + g_free (uri->fragment); uri->fragment = g_strdup (fragment); return TRUE; -- 2.7.4