Skip to content

Commit

Permalink
Merge pull request #4154 from Liamolucko/check-home
Browse files Browse the repository at this point in the history
Check if a candidate home directory exists before using it
  • Loading branch information
Sonicadvance1 authored Nov 6, 2024
2 parents 5ad7fdb + 7a61d9d commit e675f42
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Common/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,17 @@ const char* GetHomeDirectory() {
const char* HomeDir = getenv("HOME");

// Try to get home directory from uid
if (!HomeDir) {
if (!HomeDir || !FHU::Filesystem::Exists(HomeDir)) {
HomeDir = FindUserHomeThroughUID();
}

// try the PWD
if (!HomeDir) {
if (!HomeDir || !FHU::Filesystem::Exists(HomeDir)) {
HomeDir = getenv("PWD");
}

// Still doesn't exit? You get local
if (!HomeDir) {
if (!HomeDir || !FHU::Filesystem::Exists(HomeDir)) {
HomeDir = ".";
}

Expand Down

0 comments on commit e675f42

Please sign in to comment.