From 0daa92cc578f178f62adc2485f9b18d774c2f27d Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Thu, 14 Jun 2012 15:17:15 +0200 Subject: [PATCH] don't segfault if XDG_CONFIG_HOME is not set --- dunst.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dunst.c b/dunst.c index ae4be05..ea36251 100644 --- a/dunst.c +++ b/dunst.c @@ -837,6 +837,7 @@ parse_dunstrc(void) { rule_t *last_rule; rule_t *new_rule; char *key; + char *config_path = NULL; int nsec = 0; int i; @@ -848,7 +849,16 @@ parse_dunstrc(void) { if (config_file == NULL) { config_file = malloc(sizeof(char) * BUFSIZ); memset(config_file, '\0', BUFSIZ); - strcat(config_file, getenv("XDG_CONFIG_HOME")); + + config_path = getenv("XDG_CONFIG_HOME"); + + if (!config_path) { + puts("no dunstrc found -> skipping\n"); + return; + } + + + strcat(config_file, config_path); strcat(config_file, "/"); strcat(config_file, "dunstrc"); }