Skip to content

Commit a9d548c

Browse files
committed
Applying sanity checks
1 parent f861a80 commit a9d548c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Launcher.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,19 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
247247
return false;
248248
}
249249

250-
bool isDevScript(std::wstring scriptPath) {
251-
int finalSlash = scriptPath.find_last_of('\\');
252-
int nextToLastSlash = scriptPath.find_last_of(L'\\', finalSlash - 1) + 1;
253-
std::wstring folderName(&scriptPath[nextToLastSlash], &scriptPath[finalSlash]);
254-
return folderName == L"src";
250+
bool isDevScript(std::wstring scriptPath)
251+
{
252+
const auto finalSlash = scriptPath.find_last_of(L'\\');
253+
if (finalSlash == std::wstring::npos || finalSlash == 0)
254+
{
255+
return false;
256+
}
257+
const auto nextToLastSlash = scriptPath.find_last_of(L'\\', finalSlash - 1);
258+
if (nextToLastSlash == std::wstring::npos)
259+
{
260+
return false;
261+
}
262+
return scriptPath.compare(nextToLastSlash + 1, finalSlash - 1 - nextToLastSlash, L"src") == 0;
255263
}
256264

257265
std::vector<std::string> ConvertToACP(std::vector<std::wstring> commandLine)

0 commit comments

Comments
 (0)