[PATCH v2 0/1] MR4944: dlls/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(a)gmail.com> -- v2: dlls/msvcrt: Free previous environment variable when clearing https://gitlab.winehq.org/wine/wine/-/merge_requests/4944
From: David Kahurani <k.kahurani(a)gmail.com> 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(a)gmail.com> --- dlls/msvcrt/environ.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/msvcrt/environ.c b/dlls/msvcrt/environ.c index aa857afa615..a0d2e08c7d0 100644 --- a/dlls/msvcrt/environ.c +++ b/dlls/msvcrt/environ.c @@ -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]; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4944
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4944
participants (3)
-
David Kahurani -
David Kahurani (@kahurani) -
Piotr Caban (@piotr)