From 3b559d89ec39b4479bf97aa376f7e685997db0a3 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 14 Dec 2012 11:47:12 -0600 Subject: If the HOME environment variable isn't set, fall back on to PWD. Closes 5584. --- Source/Core/Common/Src/FileUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/Src/FileUtil.cpp') diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 4650c6e1ba..691685e99d 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -649,7 +649,7 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath) if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; else - paths[D_USER_IDX] = std::string(getenv("HOME")) + DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; + paths[D_USER_IDX] = std::string(getenv("HOME") ? getenv("HOME") : getenv("PWD")) + DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; #endif INFO_LOG(COMMON, "GetUserPath: Setting user directory to %s:", paths[D_USER_IDX].c_str()); -- cgit v1.2.3 From 2db4549174620aa130ef012af26c2e1760c4928c Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 18 Dec 2012 23:35:28 -0600 Subject: Fix a memory leak based on Lioncash's patches. --- Source/Core/Common/Src/FileUtil.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Source/Core/Common/Src/FileUtil.cpp') diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 691685e99d..77aac45418 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -299,7 +299,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) ERROR_LOG(COMMON, "Copy: failed reading from source, %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); - return false; + goto bail; } } @@ -310,13 +310,19 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) ERROR_LOG(COMMON, "Copy: failed writing to output, %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); - return false; + goto bail; } } // close flushs fclose(input); fclose(output); return true; +bail: + if (input) + fclose(input); + if (output) + fclose(output); + return false; #endif } -- cgit v1.2.3