Author: tkreuzer
Date: Tue Nov 27 03:28:40 2007
New Revision: 30800
URL:
http://svn.reactos.org/svn/reactos?rev=30800&view=rev
Log:
- implement GrowIfNecessary_dbg() using file and line from the caller to cmd_alloc_dbg
memory.
- fix memory allocation size, respecting the terminating 0
See issue #2845 for more details.
Modified:
trunk/reactos/base/shell/cmd/cmd.c
Modified: trunk/reactos/base/shell/cmd/cmd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=3…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.c (original)
+++ trunk/reactos/base/shell/cmd/cmd.c Tue Nov 27 03:28:40 2007
@@ -1116,18 +1116,20 @@
}
BOOL
-GrowIfNecessary ( UINT needed, LPTSTR* ret, UINT* retlen )
+GrowIfNecessary_dbg ( UINT needed, LPTSTR* ret, UINT* retlen, const char *file, int line
)
{
if ( *ret && needed < *retlen )
return TRUE;
*retlen = needed;
if ( *ret )
cmd_free ( *ret );
- *ret = (LPTSTR)cmd_alloc ( *retlen * sizeof(TCHAR) );
+// *ret = (LPTSTR)cmd_alloc ( *retlen * sizeof(TCHAR) );
+ *ret = (LPTSTR)cmd_alloc_dbg ( *retlen * sizeof(TCHAR), file, line );
if ( !*ret )
SetLastError ( ERROR_OUTOFMEMORY );
return *ret != NULL;
}
+#define GrowIfNecessary(x, y, z) GrowIfNecessary_dbg(x, y, z, __FILE__, __LINE__)
LPCTSTR
GetEnvVarOrSpecial ( LPCTSTR varName )
@@ -1222,7 +1224,7 @@
return ret;
}
- GrowIfNecessary(_tcslen(varName) + 2, &ret, &retlen);
+ GrowIfNecessary(_tcslen(varName) + 3, &ret, &retlen);
_stprintf(ret,_T("%%%s%%"),varName);
return ret; /* not found - return orginal string */
}