From 8015e6f9297cc1cc4f51ae26de32986b7cd84fd8 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 21 May 2018 13:35:21 +0900 Subject: [PATCH] pmix/base: plug a memory leak in opal_pmix_base_select() Signed-off-by: Gilles Gouaillardet (cherry picked from commit open-mpi/ompi@6e47c5708e7c559108e495f06a29152e4fe02e1b) --- opal/mca/pmix/base/pmix_base_select.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opal/mca/pmix/base/pmix_base_select.c b/opal/mca/pmix/base/pmix_base_select.c index b66466afb6..53891f45c4 100644 --- a/opal/mca/pmix/base/pmix_base_select.c +++ b/opal/mca/pmix/base/pmix_base_select.c @@ -4,6 +4,8 @@ * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2016-2018 Cisco Systems, Inc. All rights reserved + * Copyright (c) 2018 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,6 +21,7 @@ #include "opal/mca/base/base.h" #include "opal/mca/pmix/pmix.h" #include "opal/mca/pmix/base/base.h" +#include "opal/util/opal_environ.h" /* * Globals @@ -33,11 +36,8 @@ int opal_pmix_base_select(void) // value of OPAL's mca_base_component_show_load_errors (i.e., the // bool variable behind Open MPI's mca_component_show_load_errors // MCA param). - char *pmix_show_load_errors_env = NULL; - asprintf(&pmix_show_load_errors_env, - "PMIX_MCA_mca_base_component_show_load_errors=%d", - mca_base_component_show_load_errors ? 1 : 0); - putenv(pmix_show_load_errors_env); + char *pmix_show_load_errors_env = mca_base_component_show_load_errors ? "1" : "0"; + opal_setenv("PMIX_MCA_mca_base_component_show_load_errors", pmix_show_load_errors_env, true, &environ); /* * Select the best component