You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2022/06/19 11:16:15 UTC

svn commit: r1902059 - in /apr/apr/trunk: CHANGES misc/win32/apr_app.c

Author: ivan
Date: Sun Jun 19 11:16:15 2022
New Revision: 1902059

URL: http://svn.apache.org/viewvc?rev=1902059&view=rev
Log:
win32: Fix double free on exit when apr_app is used on Windows. [Ivan Zhakov]

* CHANGES: Add changelog entry.

* misc/win32/apr_app.c
  (wmain): Do not free _wenviron -- MSVCRT automatically free 'initial'
   environment block on exit.

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/misc/win32/apr_app.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1902059&r1=1902058&r2=1902059&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sun Jun 19 11:16:15 2022
@@ -264,6 +264,8 @@ Changes for APR 2.0.0
   *) Fix attempt to free invalid memory on exit when apr_app is used
      on Windows. [Ivan Zhakov]
 
+  *) Fix double free on exit when apr_app is used on Windows. [Ivan Zhakov]
+
 Changes for APR and APR-util 1.7.x and later:
 
   *) http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/CHANGES?view=markup

Modified: apr/apr/trunk/misc/win32/apr_app.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/apr_app.c?rev=1902059&r1=1902058&r2=1902059&view=diff
==============================================================================
--- apr/apr/trunk/misc/win32/apr_app.c (original)
+++ apr/apr/trunk/misc/win32/apr_app.c Sun Jun 19 11:16:15 2022
@@ -91,9 +91,11 @@ int wmain(int argc, const wchar_t **warg
      * Reset _wenviron for good measure.
      */
     if (_wenviron) {
-        wenv = _wenviron;
         _wenviron = NULL;
-        free((wchar_t **)wenv);
+
+        /* There is no need to free _wenviron because MSVCRT
+         * automatically free 'initial' environment block.
+         */
     }
 
     apr_app_init_complete = 1;