diff --git a/src/mcconfig/common.c b/src/mcconfig/common.c index f386519ed..2415311b5 100644 --- a/src/mcconfig/common.c +++ b/src/mcconfig/common.c @@ -66,18 +66,15 @@ mc_config_init (const gchar * ini_path) return mc_config; } - if (((mc_stat (ini_path, &st) == 0) && (st.st_size == 0)) - || g_key_file_load_from_file - (mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL)) + if (mc_stat (ini_path, &st) && st.st_size) { - /* file is empty or normal */ - mc_config->ini_path = g_strdup (ini_path); - return mc_config; + /* file present and not empty */ + g_key_file_load_from_file + (mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL); } - g_key_file_free (mc_config->handle); - g_free (mc_config); - return NULL; + mc_config->ini_path = g_strdup (ini_path); + return mc_config; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ diff --git a/src/mcconfig/get.c b/src/mcconfig/get.c index a8a84d547..03d59c718 100644 --- a/src/mcconfig/get.c +++ b/src/mcconfig/get.c @@ -42,6 +42,7 @@ mc_config_get_groups (mc_config_t * mc_config, gsize * len) if (!mc_config) { ret = g_try_malloc0 (sizeof (gchar **)); + *len=0; return ret; } ret = g_key_file_get_groups (mc_config->handle, len); @@ -62,6 +63,7 @@ mc_config_get_keys (mc_config_t * mc_config, const gchar * group, gsize * len) if (!mc_config || !group) { ret = g_try_malloc0 (sizeof (gchar **)); + *len=0; return ret; } ret = g_key_file_get_keys (mc_config->handle, group, len, NULL);