]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: free memory returned by windows GetEnvironmentStrings
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 9 Aug 2010 01:30:33 +0000 (11:30 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 9 Aug 2010 01:30:33 +0000 (11:30 +1000)
R=golang-dev
CC=golang-dev
https://golang.org/cl/1917048

src/pkg/runtime/windows/thread.c

index f18d960a7e8b83d9670a684d074b173538d04aeb..38e0c9ddb83f7f774b91e0ac35a0ac691530f068 100644 (file)
@@ -85,7 +85,7 @@ windows_goargs(void)
        extern Slice os·Args;
        extern Slice os·Envs;
 
-       void *gcl, *clta, *ges;
+       void *gcl, *clta, *ges, *fes;
        uint16 *cmd, *env, **argv;
        String *gargv;
        String *genvv;
@@ -95,6 +95,7 @@ windows_goargs(void)
        gcl = get_proc_addr("kernel32.dll", "GetCommandLineW");
        clta = get_proc_addr("shell32.dll", "CommandLineToArgvW");
        ges = get_proc_addr("kernel32.dll", "GetEnvironmentStringsW");
+       fes = get_proc_addr("kernel32.dll", "FreeEnvironmentStringsW");
 
        cmd = stdcall(gcl, 0);
        env = stdcall(ges, 0);
@@ -121,6 +122,8 @@ windows_goargs(void)
        os·Envs.array = (byte*)genvv;
        os·Envs.len = envc;
        os·Envs.cap = envc;
+
+       stdcall(fes, 1, env);
 }
 
 void