mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 568079: No need to check for NULL before free()
Change-Id: I4948ce07ed4ec426ce2a3bac226281409c25f7c9 Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
3ae7b88630
commit
570c5b7ff0
10 changed files with 17 additions and 47 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -47,7 +47,7 @@ static void print_array(char **c_array) {
|
||||||
static char** alloc_c_array(JNIEnv *env, jobjectArray j_array) {
|
static char** alloc_c_array(JNIEnv *env, jobjectArray j_array) {
|
||||||
int i;
|
int i;
|
||||||
jint c_array_size = (*env)->GetArrayLength(env, j_array);
|
jint c_array_size = (*env)->GetArrayLength(env, j_array);
|
||||||
char **c_array = calloc(c_array_size + 1, sizeof(*c_array));
|
char **c_array = calloc(c_array_size + 1, sizeof(char*));
|
||||||
|
|
||||||
if (c_array == NULL) {
|
if (c_array == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -67,9 +67,7 @@ static char** alloc_c_array(JNIEnv *env, jobjectArray j_array) {
|
||||||
static void free_c_array(char **c_array) {
|
static void free_c_array(char **c_array) {
|
||||||
if (c_array) {
|
if (c_array) {
|
||||||
for (char **p = c_array; *p; p++) {
|
for (char **p = c_array; *p; p++) {
|
||||||
if (*p) {
|
free(*p);
|
||||||
free(*p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(c_array);
|
free(c_array);
|
||||||
}
|
}
|
||||||
|
@ -121,12 +119,8 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *
|
||||||
|
|
||||||
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||||
(*env)->ReleaseStringUTFChars(env, jslaveName, pts_name);
|
(*env)->ReleaseStringUTFChars(env, jslaveName, pts_name);
|
||||||
if (cmd) {
|
free_c_array(cmd);
|
||||||
free_c_array(cmd);
|
free_c_array(envp);
|
||||||
}
|
|
||||||
if (envp) {
|
|
||||||
free_c_array(envp);
|
|
||||||
}
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,12 +156,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *env, jobject jobj, jobj
|
||||||
}
|
}
|
||||||
|
|
||||||
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||||
if (cmd) {
|
free_c_array(cmd);
|
||||||
free_c_array(cmd);
|
free_c_array(envp);
|
||||||
}
|
|
||||||
if (envp) {
|
|
||||||
free_c_array(envp);
|
|
||||||
}
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,12 +214,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject jobj, jobj
|
||||||
}
|
}
|
||||||
|
|
||||||
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
bail_out: (*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||||
if (cmd) {
|
free_c_array(cmd);
|
||||||
free_c_array(cmd);
|
free_c_array(envp);
|
||||||
}
|
|
||||||
if (envp) {
|
|
||||||
free_c_array(envp);
|
|
||||||
}
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *
|
||||||
PROCESS_INFORMATION pi = { 0 }, *piCopy;
|
PROCESS_INFORMATION pi = { 0 }, *piCopy;
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
DWORD flags = 0;
|
DWORD flags = 0;
|
||||||
const wchar_t *cwd = NULL;
|
wchar_t *cwd = NULL;
|
||||||
LPVOID envBlk = NULL;
|
LPVOID envBlk = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int nCmdLineLength = 0;
|
int nCmdLineLength = 0;
|
||||||
|
@ -372,17 +372,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *
|
||||||
&si, /* (in) startup information */
|
&si, /* (in) startup information */
|
||||||
&pi); /* (out) process information */
|
&pi); /* (out) process information */
|
||||||
|
|
||||||
if (NULL != cwd) {
|
free(cwd);
|
||||||
free((void*) cwd);
|
free(szEnvBlock);
|
||||||
}
|
free(szCmdLine);
|
||||||
|
|
||||||
if (NULL != szEnvBlock) {
|
|
||||||
free(szEnvBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != szCmdLine) {
|
|
||||||
free(szCmdLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ret) { // Launching error
|
if (!ret) { // Launching error
|
||||||
char *lpMsgBuf;
|
char *lpMsgBuf;
|
||||||
|
@ -572,15 +564,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *
|
||||||
&si, /* (in) startup information */
|
&si, /* (in) startup information */
|
||||||
&pi); /* (out) process information */
|
&pi); /* (out) process information */
|
||||||
|
|
||||||
if (NULL != cwd) {
|
free(cwd);
|
||||||
free(cwd);
|
free(szEnvBlock);
|
||||||
}
|
free(szCmdLine);
|
||||||
if (NULL != szEnvBlock) {
|
|
||||||
free(szEnvBlock);
|
|
||||||
}
|
|
||||||
if (NULL != szCmdLine) {
|
|
||||||
free(szCmdLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ret) { // error
|
if (!ret) { // error
|
||||||
char *lpMsgBuf;
|
char *lpMsgBuf;
|
||||||
|
|
|
@ -430,9 +430,7 @@ int main() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != szCmdLine) {
|
free(szCmdLine);
|
||||||
free(szCmdLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(waitEvent);
|
CloseHandle(waitEvent);
|
||||||
CloseHandle(h[0]);
|
CloseHandle(h[0]);
|
||||||
|
@ -441,7 +439,7 @@ int main() {
|
||||||
CloseHandle(h[3]);
|
CloseHandle(h[3]);
|
||||||
CloseHandle(h[4]);
|
CloseHandle(h[4]);
|
||||||
|
|
||||||
return (dwExitCode);
|
return dwExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue