Skip to content

Commit efac15e

Browse files
committed
ompi: use opal_setenv instead of putenv
this fixes a memory leak at finalize Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 981dcca commit efac15e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

ompi/runtime/ompi_mpi_init.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "opal/mca/btl/base/base.h"
6262
#include "opal/mca/pmix/pmix.h"
6363
#include "opal/util/timings.h"
64+
#include "opal/util/opal_environ.h"
6465

6566
#include "ompi/constants.h"
6667
#include "ompi/mpi/fortran/base/constants.h"
@@ -378,7 +379,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
378379
ompi_proc_t** procs;
379380
size_t nprocs;
380381
char *error = NULL;
381-
char *cmd=NULL, *av=NULL;
382382
ompi_errhandler_errtrk_t errtrk;
383383
volatile bool active;
384384
opal_list_t info;
@@ -484,15 +484,13 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
484484
* the requested thread level
485485
*/
486486
if (NULL == getenv("OMPI_COMMAND") && NULL != argv && NULL != argv[0]) {
487-
asprintf(&cmd, "OMPI_COMMAND=%s", argv[0]);
488-
putenv(cmd);
487+
opal_setenv("OMPI_COMMAND", argv[0], true, &environ);
489488
}
490489
if (NULL == getenv("OMPI_ARGV") && 1 < argc) {
491490
char *tmp;
492491
tmp = opal_argv_join(&argv[1], ' ');
493-
asprintf(&av, "OMPI_ARGV=%s", tmp);
492+
opal_setenv("OMPI_ARGV", tmp, true, &environ);
494493
free(tmp);
495-
putenv(av);
496494
}
497495

498496
/* open the rte framework */

0 commit comments

Comments
 (0)