kernel32/tests: Free environment block in the child process when it is unused.

This commit is contained in:
Andrew Nguyen 2011-01-16 04:35:21 -06:00 committed by Alexandre Julliard
parent e6da2aec8f
commit ba7f7046ee
1 changed files with 6 additions and 4 deletions

View File

@ -249,8 +249,8 @@ static void doChild(const char* file, const char* option)
STARTUPINFOA siA;
STARTUPINFOW siW;
int i;
char* ptrA;
WCHAR* ptrW;
char *ptrA, *ptrA_save;
WCHAR *ptrW, *ptrW_save;
char bufA[MAX_PATH];
WCHAR bufW[MAX_PATH];
HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
@ -311,7 +311,7 @@ static void doChild(const char* file, const char* option)
childPrintf(hFile, "CommandLineW=%s\n\n", encodeW(GetCommandLineW()));
/* output of environment (Ansi) */
ptrA = GetEnvironmentStringsA();
ptrA_save = ptrA = GetEnvironmentStringsA();
if (ptrA)
{
char env_var[MAX_LISTED_ENV_VAR];
@ -326,10 +326,11 @@ static void doChild(const char* file, const char* option)
ptrA += strlen(ptrA) + 1;
}
childPrintf(hFile, "len=%d\n\n", i);
FreeEnvironmentStringsA(ptrA_save);
}
/* output of environment (Unicode) */
ptrW = GetEnvironmentStringsW();
ptrW_save = ptrW = GetEnvironmentStringsW();
if (ptrW)
{
WCHAR env_var[MAX_LISTED_ENV_VAR];
@ -345,6 +346,7 @@ static void doChild(const char* file, const char* option)
ptrW += lstrlenW(ptrW) + 1;
}
childPrintf(hFile, "len=%d\n\n", i);
FreeEnvironmentStringsW(ptrW_save);
}
childPrintf(hFile, "[Misc]\n");