mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
- Do not free the environment strings from the initial environment.
svn path=/trunk/; revision=4811
This commit is contained in:
parent
ec5e98348c
commit
cdeedf3bb4
2 changed files with 9 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: dllmain.c,v 1.18 2003/04/24 16:34:26 hbirr Exp $
|
/* $Id: dllmain.c,v 1.19 2003/06/01 17:08:03 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.18 $
|
* $Revision: 1.19 $
|
||||||
* $Author: hbirr $
|
* $Author: hbirr $
|
||||||
* $Date: 2003/04/24 16:34:26 $
|
* $Date: 2003/06/01 17:08:03 $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
|
||||||
{
|
{
|
||||||
if (__initenv && __initenv != _environ)
|
if (__initenv && __initenv != _environ)
|
||||||
{
|
{
|
||||||
|
FreeEnvironmentStringsA(__initenv[0]);
|
||||||
free(__initenv);
|
free(__initenv);
|
||||||
__initenv = NULL;
|
__initenv = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: environ.c,v 1.2 2003/04/24 16:34:26 hbirr Exp $
|
/* $Id: environ.c,v 1.3 2003/06/01 17:08:03 hbirr Exp $
|
||||||
*
|
*
|
||||||
* dllmain.c
|
* dllmain.c
|
||||||
*
|
*
|
||||||
|
@ -42,14 +42,10 @@ int BlockEnvToEnviron(void)
|
||||||
|
|
||||||
DPRINT("BlockEnvToEnviron()\n");
|
DPRINT("BlockEnvToEnviron()\n");
|
||||||
|
|
||||||
if (_environ) {
|
if (_environ && _environ != __initenv) {
|
||||||
FreeEnvironmentStringsA(_environ[0]);
|
FreeEnvironmentStringsA(_environ[0]);
|
||||||
if (__initenv == _environ) {
|
|
||||||
__initenv[0] == NULL;
|
|
||||||
} else {
|
|
||||||
free(_environ);
|
free(_environ);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_environ = NULL;
|
_environ = NULL;
|
||||||
ptr2 = ptr = (char*)GetEnvironmentStringsA();
|
ptr2 = ptr = (char*)GetEnvironmentStringsA();
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
|
@ -59,7 +55,7 @@ int BlockEnvToEnviron(void)
|
||||||
len = 0;
|
len = 0;
|
||||||
while (*ptr2) {
|
while (*ptr2) {
|
||||||
len++;
|
len++;
|
||||||
while (*ptr2++);
|
ptr2 += strlen(ptr2) + 1;
|
||||||
}
|
}
|
||||||
_environ = malloc((len + 1) * sizeof(char*));
|
_environ = malloc((len + 1) * sizeof(char*));
|
||||||
if (_environ == NULL) {
|
if (_environ == NULL) {
|
||||||
|
@ -68,7 +64,7 @@ int BlockEnvToEnviron(void)
|
||||||
}
|
}
|
||||||
for (i = 0; i < len && *ptr; i++) {
|
for (i = 0; i < len && *ptr; i++) {
|
||||||
_environ[i] = ptr;
|
_environ[i] = ptr;
|
||||||
while (*ptr++);
|
ptr += strlen(ptr) + 1;
|
||||||
}
|
}
|
||||||
_environ[i] = NULL;
|
_environ[i] = NULL;
|
||||||
if (__initenv == NULL)
|
if (__initenv == NULL)
|
||||||
|
|
Loading…
Reference in a new issue