kernel32/tests: Free environment strings buffer at the conclusion of the environment tests.

This commit is contained in:
Andrew Nguyen 2011-01-21 05:02:57 -06:00 committed by Alexandre Julliard
parent 6c8f8a64b0
commit 70d67becac

View file

@ -1102,10 +1102,11 @@ static void test_Environment(void)
char buffer[MAX_PATH];
PROCESS_INFORMATION info;
STARTUPINFOA startup;
char* child_env;
char *child_env;
int child_env_len;
char* ptr;
char* env;
char *ptr;
char *ptr2;
char *env;
int slen;
memset(&startup, 0, sizeof(startup));
@ -1122,7 +1123,8 @@ static void test_Environment(void)
/* child process has changed result file, so let profile functions know about it */
WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
cmpEnvironment(GetEnvironmentStringsA());
env = GetEnvironmentStringsA();
cmpEnvironment(env);
release_memory();
assert(DeleteFileA(resfile) != 0);
@ -1136,7 +1138,7 @@ static void test_Environment(void)
sprintf(buffer, "\"%s\" tests/process.c \"%s\"", selfname, resfile);
child_env_len = 0;
ptr = GetEnvironmentStringsA();
ptr = env;
while(*ptr)
{
slen = strlen(ptr)+1;
@ -1161,13 +1163,13 @@ static void test_Environment(void)
* - PATH (already set above)
* - the directory definitions (=[A-Z]:=)
*/
for (env = GetEnvironmentStringsA(); *env; env += strlen(env) + 1)
for (ptr2 = env; *ptr2; ptr2 += strlen(ptr2) + 1)
{
if (strncmp(env, "PATH=", 5) != 0 &&
strncmp(env, "WINELOADER=", 11) != 0 &&
!is_str_env_drive_dir(env))
if (strncmp(ptr2, "PATH=", 5) != 0 &&
strncmp(ptr2, "WINELOADER=", 11) != 0 &&
!is_str_env_drive_dir(ptr2))
{
strcpy(ptr, env);
strcpy(ptr, ptr2);
ptr += strlen(ptr) + 1;
}
}
@ -1181,6 +1183,7 @@ static void test_Environment(void)
cmpEnvironment(child_env);
HeapFree(GetProcessHeap(), 0, child_env);
FreeEnvironmentStringsA(env);
release_memory();
assert(DeleteFileA(resfile) != 0);
}