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

Alexandre Julliard julliard at winehq.org
Fri Jan 21 11:08:19 CST 2011


Module: wine
Branch: master
Commit: 70d67becac62de216202ac9fa08c25c446291989
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=70d67becac62de216202ac9fa08c25c446291989

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Fri Jan 21 05:02:57 2011 -0600

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

---

 dlls/kernel32/tests/process.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index a0ad79e..bafd8a0 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -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));
@@ -1121,8 +1122,9 @@ static void test_Environment(void)
     ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
     /* 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);
 
@@ -1134,9 +1136,9 @@ 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();
+    ptr = env;
     while(*ptr)
     {
         slen = strlen(ptr)+1;
@@ -1146,7 +1148,7 @@ static void test_Environment(void)
     /* 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;
@@ -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;
         }
     }
@@ -1177,10 +1179,11 @@ static void test_Environment(void)
     ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
     /* child process has changed result file, so let profile functions know about it */
     WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
-    
+
     cmpEnvironment(child_env);
 
     HeapFree(GetProcessHeap(), 0, child_env);
+    FreeEnvironmentStringsA(env);
     release_memory();
     assert(DeleteFileA(resfile) != 0);
 }




More information about the wine-cvs mailing list