Zebediah Figura : ntdll: Avoid leaking the previous environment in RtlSetCurrentEnvironment().
Alexandre Julliard
julliard at winehq.org
Thu May 7 17:56:53 CDT 2020
Module: wine
Branch: master
Commit: e012bd5811784d953d576a4591c7be14234c92b9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e012bd5811784d953d576a4591c7be14234c92b9
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>
---
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 71ae48681d..3acf7f52d5 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -996,14 +996,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