update for HEAD-2003050101
[reactos.git] / lib / msvcrt / misc / dllmain.c
index 65f908e..c23e4e0 100644 (file)
@@ -42,6 +42,7 @@ extern unsigned int _winver;
 extern char* _acmdln;       /* pointer to ascii command line */
 #undef _environ
 extern char** _environ;     /* pointer to environment block */
+extern char** __initenv;    /* pointer to initial environment block */
 
 
 /* LIBRARY GLOBAL VARIABLES ***************************************************/
@@ -125,7 +126,11 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
             /* destroy heap */
             if (nAttachCount == 0)
             {
-
+               if (__initenv && __initenv != _environ)
+               {
+                   free(__initenv);
+                   __initenv = NULL;
+               }
                 if (_environ)
                 {
                     FreeEnvironmentStringsA(_environ[0]);