Don't leak memory on realloc failure

svn path=/trunk/; revision=58535
This commit is contained in:
Pierre Schweitzer 2013-03-17 12:58:53 +00:00
parent db5a7755ce
commit 58a33cba17
2 changed files with 8 additions and 0 deletions

View file

@ -377,11 +377,15 @@ INT cmd_copy(LPTSTR param)
if (size > 512)
{
TCHAR *old_evar = evar;
evar = cmd_realloc(evar,size * sizeof(TCHAR) );
if (evar!=NULL)
size = GetEnvironmentVariable (_T("COPYCMD"), evar, size);
else
{
size=0;
evar = old_evar;
}
}
/* check see if we did get any env variable */

View file

@ -666,6 +666,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
/* aseemble a list of all files names */
do
{
FileName * oldFileList = FileList;
if(!_tcscmp (file.cFileName, _T(".")) ||
!_tcscmp (file.cFileName, _T("..")))
continue;
@ -683,6 +685,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
if(FileList == NULL)
{
/* Don't leak old buffer */
cmd_free(oldFileList);
/* Assemble the orginal string and return */
_tcscpy(strOut,szOrginal);
FindClose(hFile);