From 7b6536e9124e0c9d3a8289e441647a0b4ca41a04 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 21 Oct 2006 13:46:04 +0000 Subject: [PATCH] * Add a check for whether we're operating on environ; if so, don't free anything. * Fix a small memory leak. This commit was SVN r12245. --- opal/util/opal_environ.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opal/util/opal_environ.c b/opal/util/opal_environ.c index 40a01f6c9a..0f22c3587f 100644 --- a/opal/util/opal_environ.c +++ b/opal/util/opal_environ.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -201,11 +202,16 @@ int opal_unsetenv(const char *name, char ***env) if (found) { (*env)[i] = (*env)[i + 1]; } else if (0 == strncmp((*env)[i], compare, len)) { - free((*env)[i]); +#if !defined(__WINDOWS__) + if (environ != *env) { + free((*env)[i]); + } +#endif (*env)[i] = (*env)[i + 1]; found = true; } } + free(compare); /* All done */