mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Do not free the initial environment block, if the environment changed.
svn path=/trunk/; revision=4571
This commit is contained in:
parent
0d54f93d31
commit
d7982ea298
2 changed files with 21 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dllmain.c,v 1.17 2002/11/24 18:42:23 robd Exp $
|
||||
/* $Id: dllmain.c,v 1.18 2003/04/24 16:34:26 hbirr Exp $
|
||||
*
|
||||
* dllmain.c
|
||||
*
|
||||
|
@ -14,9 +14,9 @@
|
|||
* DISCLAMED. This includes but is not limited to warrenties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.17 $
|
||||
* $Author: robd $
|
||||
* $Date: 2002/11/24 18:42:23 $
|
||||
* $Revision: 1.18 $
|
||||
* $Author: hbirr $
|
||||
* $Date: 2003/04/24 16:34:26 $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -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]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: environ.c,v 1.1 2002/11/24 18:42:23 robd Exp $
|
||||
/* $Id: environ.c,v 1.2 2003/04/24 16:34:26 hbirr Exp $
|
||||
*
|
||||
* dllmain.c
|
||||
*
|
||||
|
@ -44,9 +44,13 @@ int BlockEnvToEnviron(void)
|
|||
|
||||
if (_environ) {
|
||||
FreeEnvironmentStringsA(_environ[0]);
|
||||
free(_environ);
|
||||
_environ = NULL;
|
||||
if (__initenv == _environ) {
|
||||
__initenv[0] == NULL;
|
||||
} else {
|
||||
free(_environ);
|
||||
}
|
||||
}
|
||||
_environ = NULL;
|
||||
ptr2 = ptr = (char*)GetEnvironmentStringsA();
|
||||
if (ptr == NULL) {
|
||||
DPRINT("GetEnvironmentStringsA() returnd NULL\n");
|
||||
|
@ -67,6 +71,10 @@ int BlockEnvToEnviron(void)
|
|||
while (*ptr++);
|
||||
}
|
||||
_environ[i] = NULL;
|
||||
if (__initenv == NULL)
|
||||
{
|
||||
__initenv = _environ;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue