Zebediah Figura : ntdll: Avoid leaking the previous environment in RtlSetCurrentEnvironment().
Alexandre Julliard
julliard at winehq.org
Fri Aug 7 10:42:30 CDT 2020
Module: wine
Branch: stable
Commit: 04d635555a259112e6e0fcb3a6715941f18140f0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=04d635555a259112e6e0fcb3a6715941f18140f0
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed May 6 09:40:27 2020 -0500
ntdll: Avoid leaking the previous environment in RtlSetCurrentEnvironment().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit e012bd5811784d953d576a4591c7be14234c92b9)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/ntdll/env.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index c5175080c4..d7010cf8b7 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -973,14 +973,21 @@ NTSTATUS WINAPI RtlQueryEnvironmentVariable_U(PWSTR env,
*/
void WINAPI RtlSetCurrentEnvironment(PWSTR new_env, PWSTR* old_env)
{
+ WCHAR *prev;
+
TRACE("(%p %p)\n", new_env, old_env);
RtlAcquirePebLock();
- if (old_env) *old_env = NtCurrentTeb()->Peb->ProcessParameters->Environment;
+ prev = NtCurrentTeb()->Peb->ProcessParameters->Environment;
NtCurrentTeb()->Peb->ProcessParameters->Environment = new_env;
RtlReleasePebLock();
+
+ if (old_env)
+ *old_env = prev;
+ else
+ RtlDestroyEnvironment( prev );
}
More information about the wine-cvs
mailing list