diff options
| author | Maximilian Seidler <maximilian.seidler@soundwork.at> | 2024-07-05 22:58:47 +0200 |
|---|---|---|
| committer | Mihai Fufezan <mihai@fufexan.net> | 2024-07-07 16:59:03 +0300 |
| commit | ede1e63f69e0356eaef10e3da30b86862df38e8c (patch) | |
| tree | 724b70e93d0eac92ef69051f8b1d3a1161186f8f /src | |
| parent | cc98594c3aed0b542e03818371a4636f549f80e1 (diff) | |
config: don't crash when getenv HOME returns null
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigManager.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ff9d3a6d..12f3ac22 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -633,7 +633,12 @@ std::string CConfigManager::getConfigDir() { if (xdgConfigHome && std::filesystem::path(xdgConfigHome).is_absolute()) return xdgConfigHome; - return getenv("HOME") + std::string("/.config"); + static const char* home = getenv("HOME"); + + if (!home) + throw std::runtime_error("Neither HOME nor XDG_CONFIG_HOME is set in the environment. Cannot determine config directory."); + + return home + std::string("/.config"); } std::string CConfigManager::getMainConfigPath() { |
