Author: pschweitzer
Date: Sun Apr 7 08:51:20 2013
New Revision: 58702
URL:
http://svn.reactos.org/svn/reactos?rev=58702&view=rev
Log:
[CMD]
Fix two memory leaks
Modified:
trunk/reactos/base/shell/cmd/for.c
trunk/reactos/base/shell/cmd/path.c
Modified: trunk/reactos/base/shell/cmd/for.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/for.c?rev=5…
==============================================================================
--- trunk/reactos/base/shell/cmd/for.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/for.c [iso-8859-1] Sun Apr 7 08:51:20 2013
@@ -105,9 +105,13 @@
ULONG_PTR CharsRead = _tcslen(Buffer);
while (Len + CharsRead >= AllocLen)
{
+ LPTSTR OldContents = Contents;
Contents = cmd_realloc(Contents, (AllocLen *= 2) * sizeof(TCHAR));
if (!Contents)
+ {
+ cmd_free(OldContents);
return NULL;
+ }
}
_tcscpy(&Contents[Len], Buffer);
Len += CharsRead;
Modified: trunk/reactos/base/shell/cmd/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/path.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/path.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/path.c [iso-8859-1] Sun Apr 7 08:51:20 2013
@@ -54,7 +54,8 @@
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0)
{
- ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
+ cmd_free(pszBuffer);
+ ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
return 0;
}
else if (dwBuffer > ENV_BUFFER_SIZE)