Commit 768e51c6 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r6972] Don't corrupt the environment directly; duplicate it before modifying

it. Based on the suggestion by Yauheni Zelenko @ Cadence.
parent a4cd5be5
......@@ -11,7 +11,7 @@
HYD_status HYDT_bscd_lsf_query_node_list(struct HYD_node **node_list)
{
char *hosts, *hostname, *num_procs_str;
char *hosts, *hostname, *num_procs_str, *thosts = NULL;
int num_procs;
HYD_status status = HYD_SUCCESS;
......@@ -25,6 +25,9 @@ HYD_status HYDT_bscd_lsf_query_node_list(struct HYD_node **node_list)
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "No LSF node list found\n");
}
else {
hosts = HYDU_strdup(hosts);
thosts = hosts;
hostname = strtok(hosts, " ");
while (1) {
if (hostname == NULL)
......@@ -42,6 +45,9 @@ HYD_status HYDT_bscd_lsf_query_node_list(struct HYD_node **node_list)
hostname = strtok(NULL, " ");
}
if (thosts)
HYDU_FREE(thosts);
}
fn_exit:
......
......@@ -100,7 +100,7 @@ static HYD_status group_to_individual_nodes(char *str, char **list)
HYD_status HYDT_bscd_slurm_query_node_list(struct HYD_node **node_list)
{
char *str, *num_procs;
char *str, *num_procs, *tstr = NULL, *tnum_procs = NULL;
char *tmp1[HYD_NUM_TMP_STRINGS], *tmp2[HYD_NUM_TMP_STRINGS];
struct HYD_node *node, *tnode;
int i, j;
......@@ -117,6 +117,9 @@ HYD_status HYDT_bscd_slurm_query_node_list(struct HYD_node **node_list)
*node_list = NULL;
}
else {
tstr = HYDU_strdup(str);
tnum_procs = HYDU_strdup(num_procs);
full_str_to_groups(str, tmp1);
num_procs = strtok(num_procs, "(");
......@@ -142,6 +145,11 @@ HYD_status HYDT_bscd_slurm_query_node_list(struct HYD_node **node_list)
/* node list is provided by the bootstrap server */
HYDT_bscd_slurm_user_node_list = 0;
if (tstr)
HYDU_FREE(tstr);
if (tnum_procs)
HYDU_FREE(tnum_procs);
}
fn_exit:
......
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