Fix crash (loadstate on missing file) and memory leak (failed to write screenshot)

This commit is contained in:
mart0258 2010-08-12 06:27:06 +00:00
parent fc1ebb2597
commit e717a16398
2 changed files with 3 additions and 1 deletions

View File

@ -917,7 +917,7 @@ void FCEUI_LoadState(const char *fname)
{
FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages
}
if (!file_exists(fname) && fname != NULL)
if (fname != NULL && !file_exists(fname))
{
loadStateFailed = 1;
return; // state doesn't exist; exit cleanly

View File

@ -587,6 +587,7 @@ int SaveSnapshot(void)
if(!(pp=FCEUD_UTF8fopen(fn,"wb")))
{
free(fn);
free(compmem);
return 0;
}
free(fn);
@ -681,6 +682,7 @@ int SaveSnapshot(char fileName[512])
if(!(pp=FCEUD_UTF8fopen(fileName,"wb")))
{
free(compmem);
return 0;
}