From b84e6dfc8a288e89cebd38e3e4066a0572c4d1ff Mon Sep 17 00:00:00 2001 From: Sander Kleijwegt Date: Wed, 19 Aug 2015 17:59:35 +0200 Subject: Fix startup crash with missing HOME or LOGNAME environment variables Check whether setenv returns NULL and if so default to '~' for HOME and 'default' for LOGNAME. Signed-off-by: Sander Kleijwegt Signed-off-by: Dirk Hohndel --- linux.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'linux.c') diff --git a/linux.c b/linux.c index 3ffd997a1..8f8ec6076 100644 --- a/linux.c +++ b/linux.c @@ -55,7 +55,11 @@ const char *system_default_filename(void) int len; home = getenv("HOME"); + if (!home) + home = "~"; user = getenv("LOGNAME"); + if (!user) + user = "default"; len = strlen(home) + strlen(user) + 17; buffer = malloc(len); snprintf(buffer, len, "%s/subsurface/%s.xml", home, user); -- cgit v1.2.3-70-g09d2