avoid potential crash with EmuDirectory if we somehow got no argv or an empty path
This commit is contained in:
parent
0a7db56bef
commit
502d8c3fa0
|
@ -27,7 +27,6 @@
|
|||
// this was measured to be close to hardware average
|
||||
// a value of 1 would represent a perfect cache, but that causes
|
||||
// games to run too fast, causing a number of issues
|
||||
// code cache timing can get as low as 3
|
||||
const int kDataCacheTiming = 2;
|
||||
const int kCodeCacheTiming = 5;
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue