[svn r146] Fixes sg fault when printing debug messages.
1.1 --- a/gmyth/src/gmyth_uri.c Thu Nov 30 14:27:14 2006 +0000
1.2 +++ b/gmyth/src/gmyth_uri.c Thu Nov 30 15:07:57 2006 +0000
1.3 @@ -191,6 +191,15 @@
1.4
1.5 }
1.6
1.7 +static gchar*
1.8 +gmyth_uri_print_field( const GString* field )
1.9 +{
1.10 + if ( field != NULL && field->str != NULL && strlen(field->str) > 0 )
1.11 + return field->str;
1.12 + else
1.13 + return "";
1.14 +}
1.15 +
1.16 static void
1.17 gmyth_uri_parser_setup_and_new( GMythURI *uri, const gchar *value )
1.18 {
1.19 @@ -245,7 +254,7 @@
1.20 eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1);
1.21 if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) ) {
1.22 GString *portStr = NULL;
1.23 - GString *hostStr = g_string_new (host);
1.24 + GString *hostStr = g_string_new (host != NULL ? host : "");
1.25
1.26 hostLen = hostStr->len;
1.27 /**** host ****/
1.28 @@ -309,9 +318,9 @@
1.29 uri->query = g_string_new_len (value+currIdx+questionIdx+1, queryLen );
1.30 }
1.31 gmyth_debug( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "\
1.32 - "user = %s, password = %s.\n", __FUNCTION__, uri->host->str, uri->port,
1.33 - uri->path->str, uri->query->str, uri->fragment->str,
1.34 - uri->user->str, uri->password->str );
1.35 + "user = %s, password = %s.\n", __FUNCTION__, gmyth_uri_print_field( uri->host ), uri->port,
1.36 + gmyth_uri_print_field( uri->path ), gmyth_uri_print_field( uri->query ), gmyth_uri_print_field( uri->fragment ),
1.37 + gmyth_uri_print_field ( uri->user ), gmyth_uri_print_field( uri->password ) );
1.38
1.39 }
1.40