This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #126240] avoid leaking memory when setting $ENV{foo} on darwin
authorTony Cook <tony@develop-help.com>
Wed, 6 Jan 2016 03:27:46 +0000 (14:27 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 6 Jan 2016 03:27:46 +0000 (14:27 +1100)
My change in e396210 was incomplete, that change was intended to
force use of setenv()/unsetenv() on Darwin, but ended up using putenv()
instead, which is a leaky mechanism.

Added darwin to the list of many others that work better with setenv()/
unsetenv().

util.c

diff --git a/util.c b/util.c
index 17b62dd..7c42a1a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2178,7 +2178,7 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
        Configure doesn't test for that yet.  For Solaris, setenv() and unsetenv()
        were introduced in Solaris 9, so testing for HAS UNSETENV is sufficient.
     */
-#   if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV))
+#   if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN)
 #       if defined(HAS_UNSETENV)
         if (val == NULL) {
             (void)unsetenv(nam);