From: Christian Dywan Date: Tue, 12 Oct 2010 21:02:44 +0000 (+0200) Subject: Allow passing NULL path to sokoke_hostname_from_uri X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6331573a2c9ec16fcf0ba082e362fbbbcfb49416;p=midori Allow passing NULL path to sokoke_hostname_from_uri --- diff --git a/midori/sokoke.c b/midori/sokoke.c index e2babcc0..4add49a7 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -503,7 +503,7 @@ sokoke_spawn_app (const gchar* uri) /** * sokoke_hostname_from_uri: * @uri: an URI string - * @path: location of a string pointer + * @path: location of a string, or %NULL * * Returns the hostname of the specified URI. * @@ -519,10 +519,15 @@ sokoke_hostname_from_uri (const gchar* uri, if ((hostname = strchr (uri, '/'))) { + gchar* pathname; if (hostname[1] == '/') hostname += 2; - if ((*path = strchr (hostname, '/'))) - return g_strndup (hostname, *path - hostname); + if ((pathname = strchr (hostname, '/'))) + { + if (path != NULL) + *path = pathname; + return g_strndup (hostname, pathname - hostname); + } else return g_strdup (hostname); }