Skip to content

Commit 5803385

Browse files
committed
util/hostfile: fix a double free error
As reported at https://stackoverflow.com/questions/52707242/mpirun-segmentation-fault-whenever-i-use-a-hostfile mpirun crashes when the hostfile contains a "user@host" line. The root cause is username was not strdup'ed and free'd twice by opal_argv_free() and free() Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent 1ef45b7 commit 5803385

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

orte/util/hostfile/hostfile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* reserved.
1414
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
16-
* Copyright (c) 2015-2017 Research Organization for Information Science
16+
* Copyright (c) 2015-2018 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
@@ -159,7 +159,7 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
159159
if (1 == cnt) {
160160
node_name = strdup(argv[0]);
161161
} else if (2 == cnt) {
162-
username = argv[0];
162+
username = strdup(argv[0]);
163163
node_name = strdup(argv[1]);
164164
} else {
165165
opal_output(0, "WARNING: Unhandled user@host-combination\n"); /* XXX */
@@ -274,7 +274,7 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
274274
if (1 == cnt) {
275275
node_name = strdup(argv[0]);
276276
} else if (2 == cnt) {
277-
username = argv[0];
277+
username = strdup(argv[0]);
278278
node_name = strdup(argv[1]);
279279
} else {
280280
opal_output(0, "WARNING: Unhandled user@host-combination\n"); /* XXX */

0 commit comments

Comments
 (0)