Skip to content

Commit 37c42b9

Browse files
seritoolsmbilker
authored andcommitted
Stub FreeEnvironmentStringsW to just leak on NT 3.1
Yup, this function just doesn't exist on NT 3.1, so `env::vars`/`env::vars_os` will just leak the OS-allocated buffer. Signed-off-by: Dennis Duda <git@seri.tools>
1 parent 64a74a2 commit 37c42b9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

library/std/src/sys/windows/c.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,13 @@ compat_fn_with_fallback! {
529529
Sleep(0);
530530
TRUE
531531
}
532+
533+
// >= NT 3.5+, 95+
534+
// https://docs.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-freeenvironmentstringsw
535+
pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL {
536+
// just leak it on NT 3.1
537+
TRUE
538+
}
532539
}
533540

534541
compat_fn_optional! {

library/std/src/sys/windows/c/windows_sys.lst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,6 @@ Windows.Win32.System.Diagnostics.Debug.M128A
24282428
Windows.Win32.System.Diagnostics.Debug.PVECTORED_EXCEPTION_HANDLER
24292429
Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT
24302430
Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT
2431-
Windows.Win32.System.Environment.FreeEnvironmentStringsW
24322431
Windows.Win32.System.Environment.GetCommandLineW
24332432
Windows.Win32.System.Environment.GetCurrentDirectoryW
24342433
Windows.Win32.System.Environment.GetEnvironmentStringsW

library/std/src/sys/windows/c/windows_sys.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ extern "system" {
168168
) -> u32;
169169
}
170170
#[link(name = "kernel32")]
171-
extern "system" {
172-
pub fn FreeEnvironmentStringsW(penv: PCWSTR) -> BOOL;
173-
}
174-
#[link(name = "kernel32")]
175171
extern "system" {
176172
pub fn GetCommandLineW() -> PCWSTR;
177173
}

0 commit comments

Comments
 (0)