Commit 3b8fefea authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

remove pointer checks before calling free()

parent 6d7eb3a1
......@@ -359,9 +359,7 @@ void kwsysProcess_Delete(kwsysProcess* cp)
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDIN, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDOUT, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDERR, 0);
if (cp->CommandExitCodes) {
free(cp->CommandExitCodes);
}
free(cp->CommandExitCodes);
free(cp->ProcessResults);
free(cp);
}
......@@ -1514,9 +1512,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
oldForkPIDs = cp->ForkPIDs;
cp->ForkPIDs = (volatile pid_t*)malloc(sizeof(volatile pid_t) *
(size_t)(cp->NumberOfCommands));
if (oldForkPIDs) {
kwsysProcessVolatileFree(oldForkPIDs);
}
kwsysProcessVolatileFree(oldForkPIDs);
if (!cp->ForkPIDs) {
return 0;
}
......@@ -1524,9 +1520,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
cp->ForkPIDs[i] = 0; /* can't use memset due to volatile */
}
if (cp->CommandExitCodes) {
free(cp->CommandExitCodes);
}
free(cp->CommandExitCodes);
cp->CommandExitCodes =
(int*)malloc(sizeof(int) * (size_t)(cp->NumberOfCommands));
if (!cp->CommandExitCodes) {
......
......@@ -523,9 +523,7 @@ void kwsysProcess_Delete(kwsysProcess* cp)
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDIN, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDOUT, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDERR, 0);
if (cp->CommandExitCodes) {
free(cp->CommandExitCodes);
}
free(cp->CommandExitCodes);
free(cp->ProcessResults);
free(cp);
}
......@@ -1607,9 +1605,7 @@ int kwsysProcessInitialize(kwsysProcess* cp)
}
ZeroMemory(cp->ProcessInformation,
sizeof(PROCESS_INFORMATION) * cp->NumberOfCommands);
if (cp->CommandExitCodes) {
free(cp->CommandExitCodes);
}
free(cp->CommandExitCodes);
cp->CommandExitCodes = (DWORD*)malloc(sizeof(DWORD) * cp->NumberOfCommands);
if (!cp->CommandExitCodes) {
return 0;
......@@ -2362,9 +2358,7 @@ static int kwsysProcess_List__New_NT4(kwsysProcess_List* self)
static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self)
{
/* Free the process information buffer. */
if (self->Buffer) {
free(self->Buffer);
}
free(self->Buffer);
}
static int kwsysProcess_List__Update_NT4(kwsysProcess_List* self)
......
......@@ -687,9 +687,7 @@ int main(int argc, const char* argv[])
fflush(stdout);
fflush(stderr);
#if defined(_WIN32)
if (argv0) {
free(argv0);
}
free(argv0);
#endif
return r;
} else if (argc > 2 && strcmp(argv[1], "0") == 0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment