From ce6b44d476beda68b4c9d22599407822e8c6a31a Mon Sep 17 00:00:00 2001 From: Tim Prins Date: Thu, 29 Mar 2007 01:02:26 +0000 Subject: [PATCH] Fix a couple of minor memory leaks This commit was SVN r14166. --- opal/mca/base/mca_base_param.c | 14 ++++++++------ opal/util/opal_environ.c | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/opal/mca/base/mca_base_param.c b/opal/mca/base/mca_base_param.c index 992d67c324..a12056bd97 100644 --- a/opal/mca/base/mca_base_param.c +++ b/opal/mca/base/mca_base_param.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University @@ -169,11 +169,13 @@ int mca_base_param_recache_files(bool rel_path_search) #else home = getenv("USERPROFILE"); #endif /* !defined(__WINDOWS__) */ - - cwd = (char *) malloc(sizeof(char) * MAXPATHLEN); - if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) { - opal_output(0, "Error: Unable to get the current working directory\n"); - cwd = strdup("."); + + if(NULL == cwd) { + cwd = (char *) malloc(sizeof(char) * MAXPATHLEN); + if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) { + opal_output(0, "Error: Unable to get the current working directory\n"); + cwd = strdup("."); + } } asprintf(&files, diff --git a/opal/util/opal_environ.c b/opal/util/opal_environ.c index 6cdca9e0b4..68b00de21d 100644 --- a/opal/util/opal_environ.c +++ b/opal/util/opal_environ.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University @@ -115,6 +115,7 @@ int opal_setenv(const char *name, const char *value, bool overwrite, } else if (NULL == *env) { i = 0; opal_argv_append(&i, env, newvalue); + free(newvalue); return OPAL_SUCCESS; }