fix a small bug after me, and check if it really got memmory or not.
Modified: trunk/reactos/subsys/system/cmd/start.c
_____
Modified: trunk/reactos/subsys/system/cmd/start.c
--- trunk/reactos/subsys/system/cmd/start.c 2005-09-03 23:12:17 UTC
(rev 17626)
+++ trunk/reactos/subsys/system/cmd/start.c 2005-09-04 09:29:44 UTC
(rev 17627)
@@ -21,8 +21,8 @@
{
TCHAR szFullName[MAX_PATH];
TCHAR first[CMDLINE_LENGTH];
- TCHAR *rest;
- TCHAR *param;
+ TCHAR *rest = NULL;
+ TCHAR *param = NULL;
BOOL bWait = FALSE;
BOOL bBat = FALSE;
BOOL bCreate = FALSE;
@@ -30,11 +30,8 @@
PROCESS_INFORMATION prci;
STARTUPINFO stui;
+
-
-
- param[0] = _T('\0');
-
if (_tcsncmp (Rest, _T("/?"), 2) == 0)
{
ConOutResPaging(TRUE,STRING_START_HELP1);
@@ -50,7 +47,23 @@
}
rest = malloc ( _tcslen(Rest) + 1 * sizeof(TCHAR));
+ if (rest == NULL)
+ {
+ error_out_of_memory();
+ return 1;
+ }
+ param =malloc ( _tcslen(Rest) + 1 * sizeof(TCHAR));
+ if (rest == NULL)
+ {
+ free(rest);
+ error_out_of_memory();
+ return 1;
+ }
+
+ param[0] = _T('\0');
+
+
_tcscpy(rest,Rest);
/* Parsing the command that gets called by start, and it's
parameters */
@@ -63,8 +76,8 @@
for(i = 0; i < count; i++)
{
if(rest[i] == _T(' '))
- {
- param = malloc ( _tcslen(&rest[i]) + 1 *
sizeof(TCHAR));
+ {
+
_tcscpy(param,&rest[i]);
rest[i] = _T('\0');
break;
@@ -83,7 +96,7 @@
if(rest[i] == _T('\"'))
bInside = !bInside;
if((rest[i] == _T(' ')) && !bInside)
- {
+ {
_tcscpy(param,&rest[i]);
rest[i] = _T('\0');
break;
@@ -134,6 +147,7 @@
if (param != NULL)
free(param);
+
return 1;
}
@@ -148,6 +162,7 @@
if (!SearchForExecutable (_T("CMD"), szFullCmdLine))
{
error_bad_command ();
+
if (rest != NULL)
free(rest);
@@ -179,8 +194,9 @@
if (bBat == FALSE)
{
_tcscpy (szFullCmdLine, first);
- if( param )
+ if( param != NULL )
{
+
_tcscat(szFullCmdLine, _T(" ") );
_tcscat (szFullCmdLine, param);
}
@@ -224,8 +240,8 @@
ErrorMessage(GetLastError (),
_T("Error executing
CreateProcess()!!\n"));
}
-// }
+
if (rest != NULL)
free(rest);