aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-12-16 00:38:10 +0100
committerStapleButter <thetotalworm@gmail.com>2018-12-16 00:38:10 +0100
commit502d8c3fa03cf8049ca76e3f8ec3838c884134b5 (patch)
treed3f882d9d32b4d6d4557efe3aa52fa9daafb81fa /src/libui_sdl
parent0a7db56bef7277791ae5ea8e95c06904edf30ee6 (diff)
avoid potential crash with EmuDirectory if we somehow got no argv or an empty path
Diffstat (limited to 'src/libui_sdl')
-rw-r--r--src/libui_sdl/main.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index ee6b80d..4f0d278 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -1315,7 +1315,7 @@ void OnOpenFile(uiMenuItem* item, uiWindow* window, void* blarg)
EmuRunning = prevstatus;
return;
}
-
+
int pos = strlen(file)-1;
while (file[pos] != '/' && file[pos] != '\\' && pos > 0) pos--;
strncpy(Config::LastROMFolder, file, pos);
@@ -1566,6 +1566,7 @@ int main(int argc, char** argv)
printf("melonDS " MELONDS_VERSION "\n");
printf(MELONDS_URL "\n");
+ if (argc > 0 && strlen(argv[0]) > 0)
{
int len = strlen(argv[0]);
while (len > 0)
@@ -1578,6 +1579,11 @@ int main(int argc, char** argv)
strncpy(EmuDirectory, argv[0], len);
EmuDirectory[len] = '\0';
}
+ else
+ {
+ EmuDirectory = new char[2];
+ strcpy(EmuDirectory, ".");
+ }
// http://stackoverflow.com/questions/14543333/joystick-wont-work-using-sdl
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");