From a720861364609bef172961cd7e99267a6fcf7f15 Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Wed, 28 Dec 2016 17:32:04 -0600 Subject: uri-helpers: Be more robust to invalid URIs We tried to handle invalid URIs here but failed, since we free the SoupURI unconditionally. --- lib/ephy-uri-helpers.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c index 8d913efbf..6a82221a3 100644 --- a/lib/ephy-uri-helpers.c +++ b/lib/ephy-uri-helpers.c @@ -282,9 +282,12 @@ ephy_uri_decode (const char *uri_string) } g_mutex_unlock (&idna_creation_mutex); - /* Process any punycode in the host portion of the URI. */ uri = soup_uri_new (uri_string); - if (uri != NULL && uri->host != NULL) { + if (uri == NULL) + return g_strdup (uri_string); + + /* Process any punycode in the host portion of the URI. */ + if (uri->host != NULL) { /* +1 so there is space for the trailing NUL with the longest-possible * domain name. +2 because ICU has this rather terrible behavior of * sometimes returning a result that's not NUL-terminated if the buffer @@ -305,7 +308,7 @@ ephy_uri_decode (const char *uri_string) } /* Note: this also strips passwords from the display URI. */ - percent_encoded_uri = uri != NULL ? soup_uri_to_string (uri, FALSE) : g_strdup (uri_string); + percent_encoded_uri = soup_uri_to_string (uri, FALSE); soup_uri_free (uri); /* Now, decode any percent-encoded characters in the URI. If there are null -- cgit v1.2.1