# HG changeset patch # User rosfran # Date 1164899277 0 # Node ID af12962f4fd2baf0bc2138ffe4601debd0aaaca8 # Parent 352ead2e7867899e8239852d45e5c35222467af0 [svn r146] Fixes sg fault when printing debug messages. diff -r 352ead2e7867 -r af12962f4fd2 gmyth/src/gmyth_uri.c --- a/gmyth/src/gmyth_uri.c Thu Nov 30 14:27:14 2006 +0000 +++ b/gmyth/src/gmyth_uri.c Thu Nov 30 15:07:57 2006 +0000 @@ -191,6 +191,15 @@ } +static gchar* +gmyth_uri_print_field( const GString* field ) +{ + if ( field != NULL && field->str != NULL && strlen(field->str) > 0 ) + return field->str; + else + return ""; +} + static void gmyth_uri_parser_setup_and_new( GMythURI *uri, const gchar *value ) { @@ -245,7 +254,7 @@ eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1); if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) ) { GString *portStr = NULL; - GString *hostStr = g_string_new (host); + GString *hostStr = g_string_new (host != NULL ? host : ""); hostLen = hostStr->len; /**** host ****/ @@ -309,9 +318,9 @@ uri->query = g_string_new_len (value+currIdx+questionIdx+1, queryLen ); } gmyth_debug( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "\ - "user = %s, password = %s.\n", __FUNCTION__, uri->host->str, uri->port, - uri->path->str, uri->query->str, uri->fragment->str, - uri->user->str, uri->password->str ); + "user = %s, password = %s.\n", __FUNCTION__, gmyth_uri_print_field( uri->host ), uri->port, + gmyth_uri_print_field( uri->path ), gmyth_uri_print_field( uri->query ), gmyth_uri_print_field( uri->fragment ), + gmyth_uri_print_field ( uri->user ), gmyth_uri_print_field( uri->password ) ); }