Prevent environment test from crashing when environment is large.

This commit is contained in:
Kevin Koltzau 2004-11-22 18:28:56 +00:00 committed by Alexandre Julliard
parent d8f4a0ab54
commit 1b8a8b26af
1 changed files with 17 additions and 1 deletions

View File

@ -834,9 +834,11 @@ static void test_Environment(void)
char buffer[MAX_PATH]; char buffer[MAX_PATH];
PROCESS_INFORMATION info; PROCESS_INFORMATION info;
STARTUPINFOA startup; STARTUPINFOA startup;
char child_env[4096]; char* child_env;
int child_env_len;
char* ptr; char* ptr;
char* env; char* env;
int slen;
memset(&startup, 0, sizeof(startup)); memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup); startup.cb = sizeof(startup);
@ -864,6 +866,19 @@ static void test_Environment(void)
/* the basics */ /* the basics */
get_file_name(resfile); get_file_name(resfile);
sprintf(buffer, "%s tests/process.c %s", selfname, resfile); sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
child_env_len = 0;
ptr = GetEnvironmentStringsA();
while(*ptr)
{
slen = strlen(ptr)+1;
child_env_len += slen;
ptr += slen;
}
/* Add space for additional environment variables */
child_env_len += 256;
child_env = HeapAlloc(GetProcessHeap(), 0, child_env_len);
ptr = child_env; ptr = child_env;
sprintf(ptr, "=%c:=%s", 'C', "C:\\FOO\\BAR"); sprintf(ptr, "=%c:=%s", 'C', "C:\\FOO\\BAR");
ptr += strlen(ptr) + 1; ptr += strlen(ptr) + 1;
@ -897,6 +912,7 @@ static void test_Environment(void)
cmpEnvironment(child_env); cmpEnvironment(child_env);
HeapFree(GetProcessHeap(), 0, child_env);
release_memory(); release_memory();
assert(DeleteFileA(resfile) != 0); assert(DeleteFileA(resfile) != 0);
} }