Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

don't segfault when no dunstrc is found

  • Loading branch information...
commit 37242bc30adac41afb414fb9051166426e5322e8 1 parent de4db5e
@knopwob authored
Showing with 10 additions and 8 deletions.
  1. +5 −4 option_parser.c
  2. +5 −4 settings.c
View
9 option_parser.c
@@ -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 {
View
9 settings.c
@@ -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: */
Please sign in to comment.
Something went wrong with that request. Please try again.