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: David Kahurani <k.kahurani@gmail.com>
This commit is contained in:
parent
9164cf8fd9
commit
1580c1133a
1 changed files with 2 additions and 0 deletions
|
@ -161,6 +161,7 @@ static int env_set(char **env, wchar_t **wenv)
|
|||
*eq = '=';
|
||||
if (!eq[1])
|
||||
{
|
||||
free(MSVCRT__environ[idx]);
|
||||
for(; MSVCRT__environ[idx]; idx++)
|
||||
MSVCRT__environ[idx] = MSVCRT__environ[idx + 1];
|
||||
}
|
||||
|
@ -187,6 +188,7 @@ static int env_set(char **env, wchar_t **wenv)
|
|||
*weq = '=';
|
||||
if (!weq[1])
|
||||
{
|
||||
free(MSVCRT__wenviron[idx]);
|
||||
for(; MSVCRT__wenviron[idx]; idx++)
|
||||
MSVCRT__wenviron[idx] = MSVCRT__wenviron[idx + 1];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue