mirror of
https://github.com/reactos/reactos.git
synced 2024-07-03 19:24:20 +00:00
[CMD]
Don't leak memory on realloc failure svn path=/trunk/; revision=58535
This commit is contained in:
parent
db5a7755ce
commit
58a33cba17
|
@ -377,11 +377,15 @@ INT cmd_copy(LPTSTR param)
|
||||||
|
|
||||||
if (size > 512)
|
if (size > 512)
|
||||||
{
|
{
|
||||||
|
TCHAR *old_evar = evar;
|
||||||
evar = cmd_realloc(evar,size * sizeof(TCHAR) );
|
evar = cmd_realloc(evar,size * sizeof(TCHAR) );
|
||||||
if (evar!=NULL)
|
if (evar!=NULL)
|
||||||
size = GetEnvironmentVariable (_T("COPYCMD"), evar, size);
|
size = GetEnvironmentVariable (_T("COPYCMD"), evar, size);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
size=0;
|
size=0;
|
||||||
|
evar = old_evar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check see if we did get any env variable */
|
/* check see if we did get any env variable */
|
||||||
|
|
|
@ -666,6 +666,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
|
||||||
/* aseemble a list of all files names */
|
/* aseemble a list of all files names */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
FileName * oldFileList = FileList;
|
||||||
|
|
||||||
if(!_tcscmp (file.cFileName, _T(".")) ||
|
if(!_tcscmp (file.cFileName, _T(".")) ||
|
||||||
!_tcscmp (file.cFileName, _T("..")))
|
!_tcscmp (file.cFileName, _T("..")))
|
||||||
continue;
|
continue;
|
||||||
|
@ -683,6 +685,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
|
||||||
|
|
||||||
if(FileList == NULL)
|
if(FileList == NULL)
|
||||||
{
|
{
|
||||||
|
/* Don't leak old buffer */
|
||||||
|
cmd_free(oldFileList);
|
||||||
/* Assemble the orginal string and return */
|
/* Assemble the orginal string and return */
|
||||||
_tcscpy(strOut,szOrginal);
|
_tcscpy(strOut,szOrginal);
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
|
|
Loading…
Reference in a new issue