[PATCH 0/1] MR1212: extrac32: Don't leak argv (Coverity)
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1212
From: Fabian Maurer <dark.shadow4(a)web.de> Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de> --- programs/extrac32/extrac32.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/programs/extrac32/extrac32.c b/programs/extrac32/extrac32.c index 3741f16b3cd..d4e7149bdde 100644 --- a/programs/extrac32/extrac32.c +++ b/programs/extrac32/extrac32.c @@ -268,29 +268,29 @@ int PASCAL wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int sho force_mode = TRUE; break; case 'L': - if ((i + 1) >= argc) return 0; + if ((i + 1) >= argc) goto cleanup; if (!GetFullPathNameW(argv[++i], MAX_PATH, path, NULL)) - return 0; + goto cleanup; break; case 'C': case 'E': case 'D': - if (cmd) return 0; + if (cmd) goto cleanup; cmd = check; break; default: - return 0; + goto cleanup; } } if (!cabfile) - return 0; + goto cleanup; if (cmd == 'C') { - if ((i + 1) != argc) return 0; + if ((i + 1) != argc) goto cleanup; if (!GetFullPathNameW(argv[i], MAX_PATH, path, NULL)) - return 0; + goto cleanup; } else if (!cmd) /* Use extraction by default if names of required files presents */ @@ -317,5 +317,7 @@ int PASCAL wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int sho extract(cabfile, path); break; } +cleanup: + HeapFree(GetProcessHeap(), 0, argv); return 0; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1212
It's going to exit anyway, so cleaning up is not very important. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1212#note_12715
On Wed Nov 2 05:38:20 2022 +0000, Nikolay Sivov wrote:
It's going to exit anyway, so cleaning up is not very important. I know, but then again, it helps avoid a warning from a static analysis tool. `get_extrac_args` uses HeapFree as well, and IMHO it's cleaner to do.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/1212#note_12716
This merge request was closed by Alexandre Julliard. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1212
I know, but then again, it helps avoid a warning from a static analysis tool. `get_extrac_args` uses HeapFree as well, and IMHO it's cleaner to do.
Freeing memory on process exit is a waste of time, and it's adding unnecessary complexity. Please don't do that. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1212#note_12739
participants (4)
-
Alexandre Julliard (@julliard) -
Fabian Maurer -
Fabian Maurer (@DarkShadow44) -
Nikolay Sivov (@nsivov)