GNOME Bugzilla – Bug 706805
libgrlnet mock data facility's ignored-parameters feature crashes for queries without parameters.
Last modified: 2013-09-08 12:01:29 UTC
I was trying to use Grilo's mock data feature in a test, and found that my test started segfaulting:
+ Trace 232418
The mock data configuration file used the ignored-parameters, but the URL in question had no query parameters. The problem code is: if (ignored_parameters) { SoupURI *uri = soup_uri_new (url); char *new_query = g_regex_replace (ignored_parameters, soup_uri_get_query (uri), -1, 0, "", 0, NULL); soup_uri_set_query (uri, *new_query ? new_query : NULL); new_url = soup_uri_to_string (uri, FALSE); soup_uri_free (uri); } else { new_url = g_strdup (url); } soup_uri_get_query() returns NULL, triggering a g_return_if_fail() assertion in g_regex_replace. This leads to new_query being set to NULL, leading to a segfault when it is dereferenced in the next statement. The parameter rewriting should only occur if the URI actually has parameters.
Created attachment 254393 [details] [review] net: Check if URL has query parameters When using the GrlNet mock, we could need to skip some of the query parameters in the URL. This commit cover the case of having an URL without any query parameter.
Attachment 254393 [details] pushed as 2ae4708 - net: Check if URL has query parameters commit 2ae4708a521d550376169cf2dde37636a02599d1 Author: Juan A. Suarez Romero <jasuarez@igalia.com> Date: Sun Sep 8 13:57:53 2013 +0200 net: Check if URL has query parameters When using the GrlNet mock, we could need to skip some of the query parameters in the URL. This commit cover the case of having an URL without any query parameter. https://bugzilla.gnome.org/show_bug.cgi?id=706805 libs/net/grl-net-mock.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)