Commit 1580c113 authored by David Kahurani's avatar David Kahurani Committed by Alexandre Julliard

msvcrt: Free previous environment variable when clearing.

Shifting the rest of the variables by one towards indices of lesser value overwrites the variable being cleared and effectively leaks it. Signed-off-by: 's avatarDavid Kahurani <k.kahurani@gmail.com>
parent 9164cf8f
...@@ -161,6 +161,7 @@ static int env_set(char **env, wchar_t **wenv) ...@@ -161,6 +161,7 @@ static int env_set(char **env, wchar_t **wenv)
*eq = '='; *eq = '=';
if (!eq[1]) if (!eq[1])
{ {
free(MSVCRT__environ[idx]);
for(; MSVCRT__environ[idx]; idx++) for(; MSVCRT__environ[idx]; idx++)
MSVCRT__environ[idx] = MSVCRT__environ[idx + 1]; MSVCRT__environ[idx] = MSVCRT__environ[idx + 1];
} }
...@@ -187,6 +188,7 @@ static int env_set(char **env, wchar_t **wenv) ...@@ -187,6 +188,7 @@ static int env_set(char **env, wchar_t **wenv)
*weq = '='; *weq = '=';
if (!weq[1]) if (!weq[1])
{ {
free(MSVCRT__wenviron[idx]);
for(; MSVCRT__wenviron[idx]; idx++) for(; MSVCRT__wenviron[idx]; idx++)
MSVCRT__wenviron[idx] = MSVCRT__wenviron[idx + 1]; MSVCRT__wenviron[idx] = MSVCRT__wenviron[idx + 1];
} }
......
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