sdl: fixed segfault when loadstating 0-9 when state did not exist
This commit is contained in:
parent
29cffedbbf
commit
f4535346fb
|
@ -890,6 +890,15 @@ void FCEUI_SaveState(const char *fname)
|
||||||
|
|
||||||
int loadStateFailed = 0; // hack, this function should return a value instead
|
int loadStateFailed = 0; // hack, this function should return a value instead
|
||||||
|
|
||||||
|
bool file_exists(const char * filename)
|
||||||
|
{
|
||||||
|
if (FILE * file = fopen(filename, "r")) //I'm sure, you meant for READING =)
|
||||||
|
{
|
||||||
|
fclose(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
void FCEUI_LoadState(const char *fname)
|
void FCEUI_LoadState(const char *fname)
|
||||||
{
|
{
|
||||||
if(!FCEU_IsValidUI(FCEUI_LOADSTATE)) return;
|
if(!FCEU_IsValidUI(FCEUI_LOADSTATE)) return;
|
||||||
|
@ -908,6 +917,11 @@ void FCEUI_LoadState(const char *fname)
|
||||||
{
|
{
|
||||||
FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages
|
FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages
|
||||||
}
|
}
|
||||||
|
if (!file_exists(fname))
|
||||||
|
{
|
||||||
|
loadStateFailed = 1;
|
||||||
|
return; // state doesn't exist; exit cleanly
|
||||||
|
}
|
||||||
if(FCEUSS_Load(fname))
|
if(FCEUSS_Load(fname))
|
||||||
{
|
{
|
||||||
//mbg todo netplay
|
//mbg todo netplay
|
||||||
|
|
Loading…
Reference in New Issue