Fixed the allocation of some buffers in Execute.

svn path=/trunk/; revision=17778
This commit is contained in:
Hartmut Birr 2005-09-10 15:20:10 +00:00
parent a03dfb5235
commit 19f7ba6b03

View file

@ -299,6 +299,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
TCHAR *first = NULL; TCHAR *first = NULL;
TCHAR *rest = NULL; TCHAR *rest = NULL;
TCHAR *full = NULL; TCHAR *full = NULL;
TCHAR *dot = NULL;
TCHAR szWindowTitle[MAX_PATH]; TCHAR szWindowTitle[MAX_PATH];
DWORD dwExitCode = 0; DWORD dwExitCode = 0;
@ -310,14 +311,14 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
need rewrite some code to use realloc when it need instead need rewrite some code to use realloc when it need instead
of add 512bytes extra */ of add 512bytes extra */
first = malloc ( _tcslen(First) + 512 * sizeof(TCHAR)); first = malloc ( (_tcslen(First) + 512) * sizeof(TCHAR));
if (first == NULL) if (first == NULL)
{ {
error_out_of_memory(); error_out_of_memory();
return ; return ;
} }
rest = malloc ( _tcslen(Rest) + 512 * sizeof(TCHAR)); rest = malloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR));
if (rest == NULL) if (rest == NULL)
{ {
free (full); free (full);
@ -325,7 +326,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
return ; return ;
} }
full = malloc ( _tcslen(Full) + 512 * sizeof(TCHAR)); full = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
if (full == NULL) if (full == NULL)
{ {
free (full); free (full);
@ -411,8 +412,8 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
GetConsoleTitle (szWindowTitle, MAX_PATH); GetConsoleTitle (szWindowTitle, MAX_PATH);
/* check if this is a .BAT or .CMD file */ /* check if this is a .BAT or .CMD file */
if (!_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".bat")) || dot = _tcsrchr (szFullName, _T('.'));
!_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".cmd"))) if (dot && (!_tcsicmp (dot, _T(".bat")) || !_tcsicmp (dot, _T(".cmd"))))
{ {
#ifdef _DEBUG #ifdef _DEBUG
DebugPrintf (_T("[BATCH: %s %s]\n"), szFullName, rest); DebugPrintf (_T("[BATCH: %s %s]\n"), szFullName, rest);