From c9660fee889e0dd5fbe1b73bed07532ef3652002 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 25 May 2022 15:19:19 -0400 Subject: [PATCH] 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 --- src/swtpm_ioctl/tpm_ioctl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/swtpm_ioctl/tpm_ioctl.c b/src/swtpm_ioctl/tpm_ioctl.c index 16c668b..9c26add 100644 --- a/src/swtpm_ioctl/tpm_ioctl.c +++ b/src/swtpm_ioctl/tpm_ioctl.c @@ -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;