Commit bc4a9caa authored by Alex Brainman's avatar Alex Brainman

runtime: free memory returned by windows GetEnvironmentStrings

R=golang-dev
CC=golang-dev
https://golang.org/cl/1917048
parent dbef0711
...@@ -85,7 +85,7 @@ windows_goargs(void) ...@@ -85,7 +85,7 @@ windows_goargs(void)
extern Slice os·Args; extern Slice os·Args;
extern Slice os·Envs; extern Slice os·Envs;
void *gcl, *clta, *ges; void *gcl, *clta, *ges, *fes;
uint16 *cmd, *env, **argv; uint16 *cmd, *env, **argv;
String *gargv; String *gargv;
String *genvv; String *genvv;
...@@ -95,6 +95,7 @@ windows_goargs(void) ...@@ -95,6 +95,7 @@ windows_goargs(void)
gcl = get_proc_addr("kernel32.dll", "GetCommandLineW"); gcl = get_proc_addr("kernel32.dll", "GetCommandLineW");
clta = get_proc_addr("shell32.dll", "CommandLineToArgvW"); clta = get_proc_addr("shell32.dll", "CommandLineToArgvW");
ges = get_proc_addr("kernel32.dll", "GetEnvironmentStringsW"); ges = get_proc_addr("kernel32.dll", "GetEnvironmentStringsW");
fes = get_proc_addr("kernel32.dll", "FreeEnvironmentStringsW");
cmd = stdcall(gcl, 0); cmd = stdcall(gcl, 0);
env = stdcall(ges, 0); env = stdcall(ges, 0);
...@@ -121,6 +122,8 @@ windows_goargs(void) ...@@ -121,6 +122,8 @@ windows_goargs(void)
os·Envs.array = (byte*)genvv; os·Envs.array = (byte*)genvv;
os·Envs.len = envc; os·Envs.len = envc;
os·Envs.cap = envc; os·Envs.cap = envc;
stdcall(fes, 1, env);
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment