From 6f2e3369b05ca48c438d303bf6fc3627b31d535b Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Fri, 4 Oct 2013 11:31:22 -0700 Subject: [PATCH] ChooseMemcardPath bugfix: check for a directory separator before converting an absolute path to a relative path. if the exe directory and the save directory had the same prefix, .../dolphin emulator/... and .../dolphin/... the path would previously have been incorrectly changed --- Source/Core/DolphinWX/Src/ConfigMain.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 7da1226d64..435559773e 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -1076,8 +1076,14 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA) #ifdef _WIN32 if (!strncmp(File::GetExeDirectory().c_str(), filename.c_str(), File::GetExeDirectory().size())) { - filename.erase(0, File::GetExeDirectory().size() +1); - filename = "./" + filename; + // If the Exe Directory Matches the prefix of the filename, we still need to verify + // that the next character is a directory separator character, otherwise we may create an invalid path + char next_char = filename.at(File::GetExeDirectory().size())+1; + if (next_char == '/' || next_char == '\\') + { + filename.erase(0, File::GetExeDirectory().size() +1); + filename = "./" + filename; + } } #endif