mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +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
|
* dllmain.c
|
||||||
*
|
*
|
||||||
|
@ -14,9 +14,9 @@
|
||||||
* DISCLAMED. This includes but is not limited to warrenties of
|
* DISCLAMED. This includes but is not limited to warrenties of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Revision: 1.17 $
|
* $Revision: 1.18 $
|
||||||
* $Author: robd $
|
* $Author: hbirr $
|
||||||
* $Date: 2002/11/24 18:42:23 $
|
* $Date: 2003/04/24 16:34:26 $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ extern unsigned int _winver;
|
||||||
extern char* _acmdln; /* pointer to ascii command line */
|
extern char* _acmdln; /* pointer to ascii command line */
|
||||||
#undef _environ
|
#undef _environ
|
||||||
extern char** _environ; /* pointer to environment block */
|
extern char** _environ; /* pointer to environment block */
|
||||||
|
extern char** __initenv; /* pointer to initial environment block */
|
||||||
|
|
||||||
|
|
||||||
/* LIBRARY GLOBAL VARIABLES ***************************************************/
|
/* LIBRARY GLOBAL VARIABLES ***************************************************/
|
||||||
|
@ -125,7 +126,11 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
|
||||||
/* destroy heap */
|
/* destroy heap */
|
||||||
if (nAttachCount == 0)
|
if (nAttachCount == 0)
|
||||||
{
|
{
|
||||||
|
if (__initenv && __initenv != _environ)
|
||||||
|
{
|
||||||
|
free(__initenv);
|
||||||
|
__initenv = NULL;
|
||||||
|
}
|
||||||
if (_environ)
|
if (_environ)
|
||||||
{
|
{
|
||||||
FreeEnvironmentStringsA(_environ[0]);
|
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
|
* dllmain.c
|
||||||
*
|
*
|
||||||
|
@ -44,9 +44,13 @@ int BlockEnvToEnviron(void)
|
||||||
|
|
||||||
if (_environ) {
|
if (_environ) {
|
||||||
FreeEnvironmentStringsA(_environ[0]);
|
FreeEnvironmentStringsA(_environ[0]);
|
||||||
free(_environ);
|
if (__initenv == _environ) {
|
||||||
_environ = NULL;
|
__initenv[0] == NULL;
|
||||||
|
} else {
|
||||||
|
free(_environ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_environ = NULL;
|
||||||
ptr2 = ptr = (char*)GetEnvironmentStringsA();
|
ptr2 = ptr = (char*)GetEnvironmentStringsA();
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
DPRINT("GetEnvironmentStringsA() returnd NULL\n");
|
DPRINT("GetEnvironmentStringsA() returnd NULL\n");
|
||||||
|
@ -67,6 +71,10 @@ int BlockEnvToEnviron(void)
|
||||||
while (*ptr++);
|
while (*ptr++);
|
||||||
}
|
}
|
||||||
_environ[i] = NULL;
|
_environ[i] = NULL;
|
||||||
|
if (__initenv == NULL)
|
||||||
|
{
|
||||||
|
__initenv = _environ;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue