Make some more dymatic buffer and correct some free()
Modified: trunk/reactos/subsys/system/cmd/cmd.c

Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c	2005-09-11 20:26:36 UTC (rev 17807)
+++ trunk/reactos/subsys/system/cmd/cmd.c	2005-09-11 20:41:39 UTC (rev 17808)
@@ -295,7 +295,7 @@
 static VOID
 Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
 {
-	TCHAR szFullName[CMDLINE_LENGTH];
+	TCHAR *szFullName=NULL;
 	TCHAR *first = NULL;
 	TCHAR *rest = NULL; 
 	TCHAR *full = NULL; 
@@ -321,7 +321,7 @@
 	rest =	malloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR)); 
 	if (rest == NULL)
 	{
-	 free (full);
+	 free (first);
 	 error_out_of_memory();
 	 return ;
 	}
@@ -329,13 +329,23 @@
 	full =	malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
 	if (full == NULL)
 	{
-	 free (full);
+	 free (first);
 	 free (rest);
 	 error_out_of_memory();
 	 return ;
 	}
 
+	szFullName = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
+	if (full == NULL)
+	{
+	 free (first);
+	 free (rest);
+	 free (full);
+	 error_out_of_memory();
+	 return ;
+	}
 
+
 	/* Though it was already parsed once, we have a different set of rules
 	   for parsing before we pass to CreateProccess */
 	if(!_tcschr(Full,_T('\"')))
@@ -398,6 +408,11 @@
 
 		if (!working) ConErrResPuts (STRING_FREE_ERROR1);
 
+		free (first);
+	    free (rest);
+	    free (full);
+		free (szFullName);
+
 		return;
 	}
 
@@ -406,6 +421,11 @@
 	if (!SearchForExecutable (first, szFullName))
 	{
 		error_bad_command ();
+
+		free (first);
+	    free (rest);
+	    free (full);
+		free (szFullName);
 		return;
 	}
 
@@ -495,7 +515,8 @@
 
  free(first);
  free(rest);
- free(full);
+ free(full); 
+ free (szFullName);
 }