From: Wouter Verhelst Date: Wed, 24 Dec 2008 15:04:59 +0000 (+0100) Subject: Improve error handling X-Git-Url: http://git.alex.org.uk Improve error handling If a config file does not even contain a single session, g_key_file_get_start_group() will return NULL, resulting in a segfault if we feed that to strcmp. Check for that possibility. This closes Fedora bug #454099, BTW. Merry christmas ;-) --- diff --git a/nbd-server.c b/nbd-server.c index c930ff4..bc390ab 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -573,6 +573,7 @@ GArray* parse_cfile(gchar* f, GError** e) { GArray *retval=NULL; gchar **groups; gboolean value; + gchar* startgroup; gint i; gint j; @@ -585,7 +586,8 @@ GArray* parse_cfile(gchar* f, GError** e) { g_key_file_free(cfile); return retval; } - if(strcmp(g_key_file_get_start_group(cfile), "generic")) { + startgroup = g_key_file_get_start_group(cfile); + if(!startgroup || strcmp(startgroup, "generic")) { g_set_error(e, errdomain, CFILE_MISSING_GENERIC, "Config file does not contain the [generic] group!"); g_key_file_free(cfile); return NULL;