orte/util: fix memory leaks
as reported by Coverity with CIDs 70845, 71855, 710652, 1196738, 1196739, 1196757, 1196758, 1269863 and 1269883
Этот коммит содержится в:
родитель
4e7b5240e4
Коммит
89806c6261
@ -11,6 +11,8 @@
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -74,12 +76,15 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
|
||||
rc = opal_argv_append_nosize(&mapped_nodes,
|
||||
mini_map[k]);
|
||||
if (OPAL_SUCCESS != rc) {
|
||||
opal_argv_free(host_argv);
|
||||
opal_argv_free(mini_map);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
opal_argv_free(mini_map);
|
||||
}
|
||||
}
|
||||
opal_argv_free(host_argv);
|
||||
|
||||
/* Did we find anything? If not, then do nothing */
|
||||
if (NULL == mapped_nodes) {
|
||||
@ -201,9 +206,6 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
|
||||
if (NULL != mapped_nodes) {
|
||||
opal_argv_free(mapped_nodes);
|
||||
}
|
||||
if (NULL != host_argv) {
|
||||
opal_argv_free(host_argv);
|
||||
}
|
||||
OPAL_LIST_DESTRUCT(&adds);
|
||||
|
||||
return rc;
|
||||
|
@ -10,6 +10,8 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -74,6 +76,11 @@ int orte_write_hnp_contact_file(char *filename)
|
||||
FILE *fp;
|
||||
char *my_uri;
|
||||
|
||||
my_uri = orte_rml.get_contact_info();
|
||||
if (NULL == my_uri) {
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
|
||||
fp = fopen(filename, "w");
|
||||
if (NULL == fp) {
|
||||
opal_output( 0, "Impossible to open the file %s in write mode\n",
|
||||
@ -82,10 +89,6 @@ int orte_write_hnp_contact_file(char *filename)
|
||||
return ORTE_ERR_FILE_OPEN_FAILURE;
|
||||
}
|
||||
|
||||
my_uri = orte_rml.get_contact_info();
|
||||
if (NULL == my_uri) {
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
fprintf(fp, "%s\n", my_uri);
|
||||
free(my_uri);
|
||||
|
||||
@ -121,9 +124,11 @@ int orte_read_hnp_contact_file(char *filename, orte_hnp_contact_t *hnp, bool con
|
||||
if (NULL == pidstr) {
|
||||
ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE);
|
||||
fclose(fp);
|
||||
free(hnp_uri);
|
||||
return ORTE_ERR_FILE_READ_FAILURE;
|
||||
}
|
||||
hnp->pid = (pid_t)atol(pidstr);
|
||||
free(pidstr);
|
||||
fclose(fp);
|
||||
|
||||
if (connect) {
|
||||
@ -133,12 +138,14 @@ int orte_read_hnp_contact_file(char *filename, orte_hnp_contact_t *hnp, bool con
|
||||
/* extract the HNP's name and store it */
|
||||
if (ORTE_SUCCESS != (rc = orte_rml_base_parse_uris(hnp_uri, &hnp->name, NULL))) {
|
||||
ORTE_ERROR_LOG(rc);
|
||||
free(hnp_uri);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* set the route to be direct */
|
||||
if (ORTE_SUCCESS != (rc = orte_routed.update_route(&hnp->name, &hnp->name))) {
|
||||
ORTE_ERROR_LOG(rc);
|
||||
free(hnp_uri);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
@ -218,14 +225,13 @@ int orte_list_local_hnps(opal_list_t *hnps, bool connect)
|
||||
} else {
|
||||
OBJ_RELEASE(hnp);
|
||||
}
|
||||
free(contact_filename);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if( NULL != cur_dirp )
|
||||
closedir(cur_dirp);
|
||||
free(headdir);
|
||||
if( NULL != contact_filename)
|
||||
free(contact_filename);
|
||||
|
||||
return (opal_list_is_empty(hnps) ? ORTE_ERR_NOT_FOUND : ORTE_SUCCESS);
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
* reserved.
|
||||
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -234,6 +236,7 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
|
||||
/* this node was already found once - add a slot and mark slots as "given" */
|
||||
node->slots++;
|
||||
ORTE_FLAG_SET(node, ORTE_NODE_FLAG_SLOTS_GIVEN);
|
||||
free(node_name);
|
||||
}
|
||||
/* do we need to record an alias for this node? */
|
||||
if (NULL != node_alias) {
|
||||
@ -298,13 +301,12 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
|
||||
node->slots = 1;
|
||||
if (NULL != username) {
|
||||
orte_set_attribute(&node->attributes, ORTE_NODE_USERNAME, ORTE_ATTR_LOCAL, username, OPAL_STRING);
|
||||
free(username);
|
||||
username = NULL;
|
||||
}
|
||||
opal_list_append(updates, &node->super);
|
||||
} else {
|
||||
/* add a slot */
|
||||
node->slots++;
|
||||
free(node_name);
|
||||
}
|
||||
OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output,
|
||||
"%s hostfile: node %s slots %d",
|
||||
@ -323,6 +325,9 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
|
||||
hostfile_parse_error(token);
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
if (NULL != username) {
|
||||
free(username);
|
||||
}
|
||||
|
||||
while (!orte_util_hostfile_done) {
|
||||
token = orte_util_hostfile_lex();
|
||||
@ -339,7 +344,6 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
|
||||
if (NULL != username) {
|
||||
orte_set_attribute(&node->attributes, ORTE_NODE_USERNAME, ORTE_ATTR_LOCAL, username, OPAL_STRING);
|
||||
free(username);
|
||||
username = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user