diff options
author | Marius Kintel <marius@kintel.net> | 2014-01-23 02:27:25 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2014-01-23 02:27:25 (GMT) |
commit | 34a758c7f68057f66898a4c49d43c6069ff3d1a5 (patch) | |
tree | 79aaf9f19749cfda4010d3f43beb76760471f62c | |
parent | 556040439e702da771659d2ddd026825bde733f6 (diff) |
bugfix: Don't crash if HOME is not set
-rw-r--r-- | src/PlatformUtils-posix.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/PlatformUtils-posix.cc b/src/PlatformUtils-posix.cc index d7b7b6d..d2b8792 100644 --- a/src/PlatformUtils-posix.cc +++ b/src/PlatformUtils-posix.cc @@ -3,8 +3,13 @@ std::string PlatformUtils::documentsPath() { - fs::path docpath(getenv("HOME")); - docpath = docpath / ".local" / "share"; - - return boosty::stringy(docpath); + const char *home = getenv("HOME"); + if (home) { + fs::path docpath(home); + docpath = docpath / ".local" / "share"; + return boosty::stringy(docpath); + } + else { + return ""; + } } |