From 1b8a8b26afd491ffa15eee36a40146a12ab12877 Mon Sep 17 00:00:00 2001 From: Kevin Koltzau Date: Mon, 22 Nov 2004 18:28:56 +0000 Subject: [PATCH] Prevent environment test from crashing when environment is large. --- dlls/kernel/tests/process.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/kernel/tests/process.c b/dlls/kernel/tests/process.c index 7d962a9f9b0..4571f15c9ae 100644 --- a/dlls/kernel/tests/process.c +++ b/dlls/kernel/tests/process.c @@ -834,9 +834,11 @@ static void test_Environment(void) char buffer[MAX_PATH]; PROCESS_INFORMATION info; STARTUPINFOA startup; - char child_env[4096]; + char* child_env; + int child_env_len; char* ptr; char* env; + int slen; memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); @@ -864,6 +866,19 @@ static void test_Environment(void) /* the basics */ get_file_name(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; sprintf(ptr, "=%c:=%s", 'C', "C:\\FOO\\BAR"); ptr += strlen(ptr) + 1; @@ -897,6 +912,7 @@ static void test_Environment(void) cmpEnvironment(child_env); + HeapFree(GetProcessHeap(), 0, child_env); release_memory(); assert(DeleteFileA(resfile) != 0); }