[PATCH 0/1] MR9994: whoami: Fix resource leak (coverity)
From: Thomas Csovcsity <thc.fr13nd@gmail.com> --- programs/whoami/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/programs/whoami/main.c b/programs/whoami/main.c index 31966ec9d66..ef842dee848 100644 --- a/programs/whoami/main.c +++ b/programs/whoami/main.c @@ -237,13 +237,13 @@ static int user(enum format format, BOOL skip_header) if (!sid) { ERR("get_process_sid failed\n"); - return 1; + goto cleanup; } if (!ConvertSidToStringSidW(sid, &sid_string)) { ERR("ConvertSidToStringSidW failed, error %ld\n", GetLastError()); - return 1; + goto cleanup; } if (format != FORMAT_CSV && !skip_header) @@ -293,6 +293,16 @@ static int user(enum format format, BOOL skip_header) LocalFree(sid_string); return 0; + +cleanup: + if (name) + free(name); + if (sid) + free(sid); + if (sid_string) + LocalFree(sid_string); + + return 1; } int __cdecl wmain(int argc, WCHAR *argv[]) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9994
This merge request was closed by Alexandre Julliard. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9994
Freeing memory in short-lived tools is not useful. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9994#note_128363
participants (3)
-
Alexandre Julliard (@julliard) -
Thomas Csovcsity -
Thomas Csovcsity (@thc13)