Commit e012bd58 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntdll: Avoid leaking the previous environment in RtlSetCurrentEnvironment().

parent d98b87a3
......@@ -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 );
}
......
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