- Don't try to free the returned buffer from getenv.

- Split the path correctly from shell command.

svn path=/trunk/; revision=17240
This commit is contained in:
Hartmut Birr
2005-08-09 15:44:54 +00:00
parent b4c4fdb519
commit fa6916cb11
+5 -11
View File
@@ -47,15 +47,11 @@ int system(const char *command)
if (szComSpec == NULL)
{
szComSpec = _strdup("cmd.exe");
if (szComSpec == NULL)
{
__set_errno(ENOMEM);
return -1;
}
szComSpec = "cmd.exe";
}
s = max(strchr(szComSpec, '\\'), strchr(szComSpec, '/'));
/* split the path from shell command */
s = max(strrchr(szComSpec, '\\'), strrchr(szComSpec, '/'));
if (s == NULL)
s = szComSpec;
else
@@ -64,7 +60,6 @@ int system(const char *command)
szCmdLine = malloc(strlen(s) + 4 + strlen(command) + 1);
if (szCmdLine == NULL)
{
free (szComSpec);
__set_errno(ENOMEM);
return -1;
}
@@ -81,7 +76,7 @@ int system(const char *command)
memset (&StartupInfo, 0, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved= NULL;
StartupInfo.dwFlags = 0;
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_SHOWDEFAULT;
StartupInfo.lpReserved2 = NULL;
StartupInfo.cbReserved2 = 0;
@@ -98,13 +93,12 @@ int system(const char *command)
NULL,
NULL,
TRUE,
0,
CREATE_NEW_PROCESS_GROUP,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);
free(szCmdLine);
free(szComSpec);
if (result == FALSE)
{