This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove intentional leak in win32/win32.c ansify_path
authorDaniel Dragan <bulk88@hotmail.com>
Mon, 19 May 2014 23:45:41 +0000 (19:45 -0400)
committerTony Cook <tony@develop-help.com>
Mon, 2 Jun 2014 01:09:39 +0000 (11:09 +1000)
The leak for was workaround for a bug (feature?) of Borland RTL where
putenv kept the passed in pointer, see commit 3e5d884e5e .
Borland was removed so this goes too. Leak found with Dr Memory.
msvcrt.dll from WinXP SP3 does not leak on a call to putenv, static linked
CRT from VC6 was confirmed to leak.

pod/perldelta.pod
win32/win32.c

index 2760ad2..03ea866 100644 (file)
@@ -465,6 +465,12 @@ index() and rindex() no longer crash when used on strings over 2GB in
 size.
 L<[perl #121562]|https://rt.perl.org/Ticket/Display.html?id=121562>.
 
+=item *
+
+A small previously intentional memory leak in PERL_SYS_INIT/PERL_SYS_INIT3 on
+Win32 builds was fixed. This might affect embedders who repeatedly create and
+destroy perl engines within the same process.
+
 =back
 
 =head1 Known Problems
index 5a112ef..9126eec 100644 (file)
@@ -4356,13 +4356,7 @@ ansify_path(void)
          * will not call mg_set() if it initializes %ENV from `environ`.
          */
         SetEnvironmentVariableA("PATH", ansi_path+5);
-        /* We are intentionally leaking the ansi_path string here because
-         * the some runtime libraries puts it directly into the environ
-         * array.  The Microsoft runtime library seems to make a copy,
-         * but will leak the copy should it be replaced again later.
-         * Since this code is only called once during PERL_SYS_INIT this
-         * shouldn't really matter.
-         */
+        win32_free(ansi_path);
     }
     win32_free(wide_path);
 }