-Fixed potential memory leak(Thanks to Dmitry Krutskih!)

-Quotes are now handled correctly on the command line in the windows port(Thanks to Dmitry Krutskih!)
This commit is contained in:
cyberwarriorx 2007-02-10 18:30:13 +00:00
parent 026bd14902
commit d81a01b6b4
2 changed files with 20 additions and 4 deletions

View File

@ -202,7 +202,12 @@ int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize)
type = ROM_DSGBA;
file = reader->Init(filename);
if (!file) return -1 ;
if (!file)
{
free(noext);
return -1;
}
size = reader->Size(file);
if(type == ROM_DSGBA)
@ -226,6 +231,7 @@ int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize)
if ((data = (u8*)malloc(mask + 1)) == NULL)
{
reader->DeInit(file);
free(noext);
return -1;
}
@ -255,7 +261,10 @@ int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize)
if (strlen(noext)>= strlen(DSGBA_EXTENSTION))
strncpy(noext + strlen(noext) - strlen(DSGBA_EXTENSTION), ".sav",strlen(DSGBA_EXTENSTION)+1);
else
return -1 ;
{
free(noext);
return -1;
}
}
else
{
@ -263,7 +272,10 @@ int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize)
if (strlen(noext)>=4)
strncpy(noext + strlen(noext) - 4, ".sav",5);
else
return -1 ;
{
free(noext);
return -1;
}
}
mc_realloc(&MMU.bupmem, bmtype, bmsize);

View File

@ -500,6 +500,10 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
runthread = CreateThread(NULL, 0, run, NULL, 0, &threadID);
// Make sure any quotes from lpszArgument are removed
if (lpszArgument[0] == '\"')
sscanf(lpszArgument, "\"%[^\"]\"", lpszArgument);
if(LoadROM(lpszArgument))
{
EnableMenuItem(menu, IDM_EXEC, MF_GRAYED);