don't segfault when no dunstrc is found
This commit is contained in:
parent
de4db5e559
commit
37242bc30a
@ -108,10 +108,7 @@ char *ini_get_string(char *section, char *key, const char *def)
|
||||
if (value)
|
||||
return g_strdup(value);
|
||||
|
||||
if (def == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return def ? g_strdup(def) : NULL;
|
||||
return def ? g_strdup(def) : NULL;
|
||||
}
|
||||
|
||||
int ini_get_int(char *section, char *key, int def)
|
||||
@ -197,6 +194,9 @@ int load_ini_file(FILE * fp)
|
||||
{
|
||||
char line[BUFSIZ];
|
||||
|
||||
if (!fp)
|
||||
return 1;
|
||||
|
||||
int line_num = 0;
|
||||
char *current_section = NULL;
|
||||
while (fgets(line, sizeof(line), fp) != NULL) {
|
||||
@ -383,6 +383,7 @@ char *option_get_string(char *ini_section, char *ini_key, char *cmdline_key,
|
||||
val = cmdline_get_string(cmdline_key, NULL, description);
|
||||
}
|
||||
|
||||
|
||||
if (val) {
|
||||
return val;
|
||||
} else {
|
||||
|
@ -49,7 +49,6 @@ void load_settings(char *cmdline_config_path)
|
||||
if (config_file == NULL) {
|
||||
puts("no dunstrc found -> skipping\n");
|
||||
xdgWipeHandle(&xdg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,9 +299,11 @@ void load_settings(char *cmdline_config_path)
|
||||
}
|
||||
|
||||
#ifndef STATIC_CONFIG
|
||||
fclose(config_file);
|
||||
free_ini();
|
||||
xdgWipeHandle(&xdg);
|
||||
if (config_file) {
|
||||
fclose(config_file);
|
||||
free_ini();
|
||||
xdgWipeHandle(&xdg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* vim: set ts=8 sw=8 tw=0: */
|
||||
|
Loading…
x
Reference in New Issue
Block a user