From 7a61d9d2b4fbf1c39f57a5cdac33142981b0d37d Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Wed, 6 Nov 2024 11:16:53 +1100 Subject: [PATCH] Check if a candidate home directory exists before using it This allows FEX to be used in situations where `HOME` is set to something invalid, e.g. inside Nix builds. --- Source/Common/Config.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Common/Config.cpp b/Source/Common/Config.cpp index 622f9942a..adb2bc156 100644 --- a/Source/Common/Config.cpp +++ b/Source/Common/Config.cpp @@ -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 = "."; }