Fix potential memory leaks

svn path=/trunk/; revision=58533
This commit is contained in:
Pierre Schweitzer 2013-03-17 11:06:37 +00:00
parent 75d957b8e6
commit c03ac4615e

View file

@ -491,10 +491,16 @@ int __cdecl compare(const void *arg1,const void *arg2)
INT ret;
File1 = cmd_alloc(sizeof(FileName));
File2 = cmd_alloc(sizeof(FileName));
if(!File1 || !File2)
if (!File1)
return 0;
File2 = cmd_alloc(sizeof(FileName));
if(!File2)
{
cmd_free(File1);
return 0;
}
memcpy(File1,arg1,sizeof(FileName));
memcpy(File2,arg2,sizeof(FileName));
@ -666,8 +672,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
/* Don't show files when they are doing 'cd' or 'rd' */
if(!ShowAll &&
file.dwFileAttributes != 0xFFFFFFFF &&
!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
file.dwFileAttributes != 0xFFFFFFFF &&
!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
continue;
}
@ -688,7 +694,7 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
} while(FindNextFile(hFile,&file));
FindClose(hFile);
FindClose(hFile);
/* Check the size of the list to see if we
found any matches */