diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-11 21:39:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-11 21:39:42 +0300 |
commit | a721e4898f71a68ecb916940864599d462880e5b (patch) | |
tree | 50442e8b86707221f498ea0f304a5314a0e67430 /src/fs/paths.cpp | |
parent | 81b97b30afa0c72e5ff17162c7d1fa88dd6187fb (diff) | |
download | plus-a721e4898f71a68ecb916940864599d462880e5b.tar.gz plus-a721e4898f71a68ecb916940864599d462880e5b.tar.bz2 plus-a721e4898f71a68ecb916940864599d462880e5b.tar.xz plus-a721e4898f71a68ecb916940864599d462880e5b.zip |
Fix different issues found by automatic checks.
Diffstat (limited to 'src/fs/paths.cpp')
-rw-r--r-- | src/fs/paths.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/fs/paths.cpp b/src/fs/paths.cpp index 06e87c2f0..050b9d00c 100644 --- a/src/fs/paths.cpp +++ b/src/fs/paths.cpp @@ -78,11 +78,11 @@ std::string getRealPath(const std::string &str) // defined(__native_client__) char *realPath = realpath(str.c_str(), nullptr); + if (!realPath) + return ""; #endif // defined(__OpenBSD__) || defined(__ANDROID__) || // defined(__native_client__) - if (!realPath) - return ""; std::string path = realPath; free(realPath); return path; @@ -105,7 +105,7 @@ bool checkPath(const std::string &path) void prepareFsPath(std::string &path) { - std::string path2 = path; +// std::string path2 = path; sanitizePath(path); // can be enabled for debugging // if (path != path2) @@ -231,11 +231,9 @@ std::string getHomePath() const char *path = getenv("HOME"); if (path == nullptr) { - uid_t uid = getuid(); - struct passwd *pw; - - pw = getpwuid(uid); - if (pw != NULL && + const uid_t uid = getuid(); + const struct passwd *const pw = getpwuid(uid); + if (pw != nullptr && pw->pw_dir != nullptr) { path = pw->pw_dir; |