From 99b2a871a76199e278aba9e10650cf3b4b8daf1c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Jul 2018 01:27:27 -0400 Subject: [PATCH] file_util: return string by const reference for GetExeDirectory() This disallows modifying the internal string buffer (which shouldn't be modified anyhow). --- src/common/file_util.cpp | 2 +- src/common/file_util.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index ac32a1fc6f..e41f2f01d7 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -591,7 +591,7 @@ std::string GetBundleDirectory() { #endif #ifdef _WIN32 -std::string& GetExeDirectory() { +const std::string& GetExeDirectory() { static std::string exe_path; if (exe_path.empty()) { wchar_t wchar_exe_path[2048]; diff --git a/src/common/file_util.h b/src/common/file_util.h index ef2f5e8dbe..4ed02f30f4 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -133,7 +133,7 @@ std::string GetBundleDirectory(); #endif #ifdef _WIN32 -std::string& GetExeDirectory(); +const std::string& GetExeDirectory(); std::string AppDataRoamingDirectory(); #endif