From 209a4eb72e466447745ee68711eb4f760a4837e9 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 27 Nov 2007 00:28:40 +0000 Subject: [PATCH] - 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. svn path=/trunk/; revision=30800 --- reactos/base/shell/cmd/cmd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index 0c4b2bd8efb..4b91266f451 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -1116,18 +1116,20 @@ VOID ParseCommandLine (LPTSTR cmd) } 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 @@ GetEnvVarOrSpecial ( LPCTSTR varName ) 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 */ }