From c4a47ae9a97f8f8a2280963df8ddbf802baa5616 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 24 Nov 2016 13:28:10 +0900 Subject: [PATCH] orte/orted: plug misc memory leaks Signed-off-by: Gilles Gouaillardet --- orte/orted/orted_submit.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/orte/orted/orted_submit.c b/orte/orted/orted_submit.c index 848ce8e3a6..8f03f25c41 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -15,7 +15,7 @@ * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. - * Copyright (c) 2015-2016 Research Organization for Information Science + * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -55,6 +55,7 @@ #ifdef HAVE_SYS_STAT_H #include #endif +#include #include "opal/dss/dss.h" #include "opal/mca/event/event.h" @@ -612,6 +613,10 @@ void orte_submit_finalize(void) close(orte_debugger_attach_fd); unlink(MPIR_attach_fifo); } + + if (NULL != orte_cmd_options.prefix) { + free(orte_cmd_options.prefix); + } } int orte_submit_cancel(int index) { @@ -703,6 +708,9 @@ int orte_submit_job(char *argv[], int *index, /* reset the globals every time thru as the argv * will modify them */ + if (NULL != orte_cmd_options.prefix) { + free(orte_cmd_options.prefix); + } memset(&orte_cmd_options, 0, sizeof(orte_cmd_options)); argc = opal_argv_count(argv); @@ -1282,12 +1290,18 @@ static int parse_locals(orte_job_t *jdata, int argc, char* argv[]) * region. * So we make a copy of the variable. */ - char *s = strdup(env[j]); + char *value, *s = strdup(env[j]); if (NULL == s) { return OPAL_ERR_OUT_OF_RESOURCE; } - putenv(s); + + value = strchr(s, '='); + if (NULL != value) { + value++; + } + opal_setenv(s, value, true, &environ); + free(s); } }