Author: pschweitzer
Date: Sun Mar 17 12:58:53 2013
New Revision: 58535
URL:
http://svn.reactos.org/svn/reactos?rev=58535&view=rev
Log:
[CMD]
Don't leak memory on realloc failure
Modified:
trunk/reactos/base/shell/cmd/copy.c
trunk/reactos/base/shell/cmd/filecomp.c
Modified: trunk/reactos/base/shell/cmd/copy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/copy.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/copy.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/copy.c [iso-8859-1] Sun Mar 17 12:58:53 2013
@@ -377,11 +377,15 @@
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 */
Modified: trunk/reactos/base/shell/cmd/filecomp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/filecomp.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] Sun Mar 17 12:58:53 2013
@@ -666,6 +666,8 @@
/* 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 @@
if(FileList == NULL)
{
+ /* Don't leak old buffer */
+ cmd_free(oldFileList);
/* Assemble the orginal string and return */
_tcscpy(strOut,szOrginal);
FindClose(hFile);