swtpm_ioctl: Free variable before parsing it to avoid memory leak (Coverity)

Avoid a memory leaks if --tcp is provided multiple times by freeing
the previously allocated memory in the tcp_hostname variable.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2022-05-25 15:19:19 -04:00 committed by Stefan Berger
parent f1306a6313
commit c9660fee88

View File

@ -967,6 +967,7 @@ int main(int argc, char *argv[])
tpm_device = optarg;
break;
case 'T':
free(tcp_hostname);
if (parse_tcp_optarg(optarg, &tcp_hostname, &tcp_port) < 0)
return EXIT_FAILURE;
break;