cli-main.c: free() argv's memory

free() memory allocated for argv to fix
Coverity 1108127, which detected it as
a resource leak.
This commit is contained in:
Moshe Kaplan 2020-12-07 08:04:40 -05:00 committed by Wireshark GitLab Utility
parent 001d0debdc
commit cea77caf41
1 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,7 @@ wmain(int argc, wchar_t *wc_argv[])
{
char **argv;
int i;
int return_code;
argv = (char **)malloc((argc + 1) * sizeof(char *));
if (argv == NULL) {
@ -67,6 +68,11 @@ wmain(int argc, wchar_t *wc_argv[])
* the cli_main.h header file since either "main" or "wmain" can be
* defined on Windows, but not both.
*/
return real_main(argc, argv);
return_code = real_main(argc, argv);
for (i = 0; i < argc; i++) {
free(argv[i]);
}
free(argv);
return return_code;
}
#endif