aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sander Kleijwegt <sander@myowndomain.nl>2015-08-19 17:59:35 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-19 10:11:31 -0700
commitb84e6dfc8a288e89cebd38e3e4066a0572c4d1ff (patch)
treeafb9e1762c0d43baa312699ffff50330d2a6cd41
parent953470d945ffd3a8c196e1649d1ea025c4775c22 (diff)
downloadsubsurface-b84e6dfc8a288e89cebd38e3e4066a0572c4d1ff.tar.gz
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 <sander@myowndomain.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--linux.c4
1 files changed, 4 insertions, 0 deletions
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);