[fix] reject empty and relative XDG storage paths

This commit is contained in:
dijunkun committed 2026-11-13 10:29:07 +08:00
1 parent ac8eff5099
commit 24f91c608a
2 files changed
+4 -2

No files matched your search

@@ -17,7 +17,8 @@ std::filesystem::path Home() {
std::filesystem::path EnvOrDefault(const char* name,
const std::filesystem::path& fallback) {
const char* value = std::getenv(name);
return value ? std::filesystem::path(value) : fallback;
const std::filesystem::path path = value ? value : "";
return path.is_absolute() ? path : fallback;
}
} // namespace
@@ -16,7 +16,8 @@ std::filesystem::path Home() {
std::filesystem::path EnvOrDefault(const char* name,
const std::filesystem::path& fallback) {
const char* value = std::getenv(name);
return value ? std::filesystem::path(value) : fallback;
const std::filesystem::path path = value ? value : "";
return path.is_absolute() ? path : fallback;
}
} // namespace