Commit 991a530d authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r7000] Memory leak fixes as reported by Yauheni Zelenko @ Cadence.

parent afa82a72
......@@ -17,6 +17,12 @@ HYD_status HYDT_bsci_finalize(void)
status = HYDT_bsci_fns.finalize();
HYDU_ERR_POP(status, "bootstrap device returned error while finalizing\n");
if (HYDT_bsci_info.bootstrap)
HYDU_FREE(HYDT_bsci_info.bootstrap);
if (HYDT_bsci_info.bootstrap_exec)
HYDU_FREE(HYDT_bsci_info.bootstrap_exec);
fn_exit:
HYDU_FUNC_EXIT();
return status;
......
......@@ -17,27 +17,24 @@ HYD_status HYDT_bsci_init(const char *user_bootstrap, const char *user_bootstrap
int enablex, int debug)
{
int i;
const char *bootstrap = NULL, *bootstrap_exec = NULL;
HYD_status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
if (user_bootstrap)
bootstrap = user_bootstrap;
else
HYD_GET_ENV_STR_VAL(bootstrap, "HYDRA_BOOTSTRAP", HYDRA_DEFAULT_BSS);
/* Store the bootstrap value as multiple bootstrap servers might
* set the same internal function pointers */
HYDT_bsci_info.bootstrap = bootstrap;
if (user_bootstrap)
HYDT_bsci_info.bootstrap = HYDU_strdup(user_bootstrap);
else
HYD_GET_ENV_STR_VAL(HYDT_bsci_info.bootstrap, "HYDRA_BOOTSTRAP", HYDRA_DEFAULT_BSS);
if (user_bootstrap_exec)
bootstrap_exec = user_bootstrap_exec;
HYDT_bsci_info.bootstrap_exec = HYDU_strdup(user_bootstrap_exec);
else
HYD_GET_ENV_STR_VAL(bootstrap_exec, "HYDRA_BOOTSTRAP_EXEC", NULL);
HYD_GET_ENV_STR_VAL(HYDT_bsci_info.bootstrap_exec, "HYDRA_BOOTSTRAP_EXEC", NULL);
for (i = 0; HYDT_bsci_comp_array[i]; i++) {
if (!strcmp(bootstrap, HYDT_bsci_comp_array[i])) {
if (!strcmp(HYDT_bsci_info.bootstrap, HYDT_bsci_comp_array[i])) {
status = (*HYDT_bsci_comp_init[i])();
HYDU_ERR_POP(status, "bootstrap device returned error initializing\n");
break;
......@@ -45,13 +42,12 @@ HYD_status HYDT_bsci_init(const char *user_bootstrap, const char *user_bootstrap
}
/* Set the appropriate info */
HYDT_bsci_info.bootstrap_exec = bootstrap_exec;
HYDT_bsci_info.enablex = enablex;
HYDT_bsci_info.debug = debug;
if (HYDT_bsci_comp_array[i] == NULL)
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR,
"unrecognized bootstrap server: %s\n", bootstrap);
"unrecognized bootstrap server: %s\n", HYDT_bsci_info.bootstrap);
/* This function is mandatory */
if (HYDT_bsci_fns.launch_procs == NULL)
......
......@@ -132,6 +132,18 @@ HYD_status HYDT_bscu_wait_for_completion(int timeout)
}
}
if (HYD_bscu_pid_list) {
HYDU_FREE(HYD_bscu_pid_list);
HYD_bscu_pid_list = NULL;
HYD_bscu_pid_count = 0;
}
if (HYD_bscu_fd_list) {
HYDU_FREE(HYD_bscu_fd_list);
HYD_bscu_fd_list = NULL;
HYD_bscu_fd_count = 0;
}
fn_exit:
HYDU_FUNC_EXIT();
return status;
......
......@@ -82,6 +82,16 @@ static HYD_status genv_fn(char *arg, char ***argv)
HYDU_ERR_POP(status, "unable to create env struct\n");
HYDU_append_env_to_list(*env, &HYD_handle.user_global.global_env.user);
HYDU_env_free(env);
if (str[0])
HYDU_FREE(str[0]);
if (str[1])
HYDU_FREE(str[1]);
if (env_name)
HYDU_FREE(env_name);
if (env_value)
HYDU_FREE(env_value);
fn_exit:
return status;
......@@ -470,6 +480,16 @@ static HYD_status env_fn(char *arg, char ***argv)
HYDU_ERR_POP(status, "get_current_exec returned error\n");
HYDU_append_env_to_list(*env, &exec->user_env);
HYDU_env_free(env);
if (str[0])
HYDU_FREE(str[0]);
if (str[1])
HYDU_FREE(str[1]);
if (env_name)
HYDU_FREE(env_name);
if (env_value)
HYDU_FREE(env_value);
fn_exit:
return status;
......
Markdown is supported
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