Skip to content

Commit f4dc7e4

Browse files
committed
orted/orted_submit: plug misc memory leaks
- always invoke init_globals() before opal_cmd_line_parse(orte_cmd_line, ...) - plug more leaks in init_globals() - remove unused env_val and personalities fields from orte_cmd_options_t Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent d5aa310 commit f4dc7e4

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

orte/orted/orted_submit.c

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,8 @@ int orte_submit_job(char *argv[], int *index,
706706

707707
/* reset the globals every time thru as the argv
708708
* will modify them */
709-
if (NULL != orte_cmd_options.prefix) {
710-
free(orte_cmd_options.prefix);
711-
}
712-
memset(&orte_cmd_options, 0, sizeof(orte_cmd_options));
709+
init_globals();
710+
713711
argc = opal_argv_count(argv);
714712

715713
/* parse the cmd line - do this every time thru so we can
@@ -1099,20 +1097,60 @@ static int init_globals(void)
10991097
orte_cmd_options.num_procs = 0;
11001098
if (NULL != orte_cmd_options.appfile) {
11011099
free(orte_cmd_options.appfile);
1100+
orte_cmd_options.appfile = NULL;
11021101
}
1103-
orte_cmd_options.appfile = NULL;
11041102
if (NULL != orte_cmd_options.wdir) {
11051103
free(orte_cmd_options.wdir);
1104+
orte_cmd_options.wdir = NULL;
11061105
}
11071106
orte_cmd_options.set_cwd_to_session_dir = false;
1108-
orte_cmd_options.wdir = NULL;
11091107
if (NULL != orte_cmd_options.path) {
11101108
free(orte_cmd_options.path);
1109+
orte_cmd_options.path = NULL;
1110+
}
1111+
if (NULL != orte_cmd_options.hnp) {
1112+
free(orte_cmd_options.hnp);
1113+
orte_cmd_options.hnp = NULL;
1114+
}
1115+
if (NULL != orte_cmd_options.stdin_target) {
1116+
free(orte_cmd_options.stdin_target);
1117+
orte_cmd_options.stdin_target = NULL ;
1118+
}
1119+
if (NULL != orte_cmd_options.output_filename) {
1120+
free(orte_cmd_options.output_filename);
1121+
orte_cmd_options.output_filename = NULL ;
1122+
}
1123+
if (NULL != orte_cmd_options.binding_policy) {
1124+
free(orte_cmd_options.binding_policy);
1125+
orte_cmd_options.binding_policy = NULL;
1126+
}
1127+
if (NULL != orte_cmd_options.mapping_policy) {
1128+
free(orte_cmd_options.mapping_policy);
1129+
orte_cmd_options.mapping_policy = NULL;
1130+
}
1131+
if (NULL != orte_cmd_options.ranking_policy) {
1132+
free(orte_cmd_options.ranking_policy);
1133+
orte_cmd_options.ranking_policy = NULL;
11111134
}
1112-
orte_cmd_options.path = NULL;
11131135

1136+
if (NULL != orte_cmd_options.report_pid) {
1137+
free(orte_cmd_options.report_pid);
1138+
orte_cmd_options.report_pid = NULL;
1139+
}
1140+
if (NULL != orte_cmd_options.report_uri) {
1141+
free(orte_cmd_options.report_uri);
1142+
orte_cmd_options.report_uri = NULL;
1143+
}
1144+
if (NULL != orte_cmd_options.slot_list) {
1145+
free(orte_cmd_options.slot_list);
1146+
orte_cmd_options.slot_list= NULL;
1147+
}
11141148
orte_cmd_options.preload_binaries = false;
1115-
orte_cmd_options.preload_files = NULL;
1149+
if (NULL != orte_cmd_options.preload_files) {
1150+
free(orte_cmd_options.preload_files);
1151+
orte_cmd_options.preload_files = NULL;
1152+
}
1153+
11161154

11171155
/* All done */
11181156
return ORTE_SUCCESS;

orte/orted/orted_submit.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
3-
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
3+
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
4+
* Copyright (c) 2017 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
46
* $COPYRIGHT$
57
*
68
* Additional copyrights may follow
@@ -51,7 +53,6 @@ struct orte_cmd_options_t {
5153
bool terminate;
5254
bool debugger;
5355
int num_procs;
54-
char *env_val;
5556
char *appfile;
5657
char *wdir;
5758
bool set_cwd_to_session_dir;
@@ -69,7 +70,6 @@ struct orte_cmd_options_t {
6970
bool index_argv;
7071
bool run_as_root;
7172
char *personality;
72-
char **personalities;
7373
bool create_dvm;
7474
bool terminate_dvm;
7575
bool nolocal;

0 commit comments

Comments
 (0)