mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
953470d945
commit
b84e6dfc8a
1 changed files with 4 additions and 0 deletions
4
linux.c
4
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);
|
||||
|
|
Loading…
Reference in a new issue