Skip to content

Commit

Permalink
consider the (rare) case that $HOME is unset (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangreffrath authored Dec 12, 2024
1 parent 8cf6e9c commit 7621899
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion prboom2/src/SDL/i_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ const char *I_ConfigDir(void)

if (!base)
{
char *home = M_getenv("HOME");
const char *home = M_getenv("HOME");
if (!home)
{
home = "/";
}

// First, try legacy directory.
base = dsda_ConcatDir(home, ".dsda-doom");
Expand Down

3 comments on commit 7621899

@fabiangreffrath
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

$ unset HOME ; ./build/dsda-doom 
Segmentation fault

After:

$ unset HOME ; ./build/dsda-doom 
Unable to create directory /.local/share/dsda-doom (2)

@jiffygist
Copy link

@jiffygist jiffygist commented on 7621899 Dec 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why / and not ~?
upd: oh that doesn't work

@fabiangreffrath
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upd: oh that doesn't work

Erm, yes, I was about to reply the same. 😁

Please sign in to comment.