From: Sebastian Dröge Date: Mon, 26 Sep 2022 11:17:18 +0000 (+0300) Subject: gsturi: When setting the same string again do nothing X-Git-Tag: 1.22.0~892 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=498ad133bada157055b281fed99b3f622fdfc8fa;p=platform%2Fupstream%2Fgstreamer.git 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: --- 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;