diff mbox series

[ima-evm-utils,v1,4/4] Change condition to free(pub)

Message ID 20221102184534.1075049-5-stefanb@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Fix some issues in evmctl | expand

Commit Message

Stefan Berger Nov. 2, 2022, 6:45 p.m. UTC
Change the condition under which pub is freed to make it clearer for the
reader and analyzer.

This change gets rid of the following gcc -fanalyzer warning:

evmctl.c:1140:12: warning: leak of ‘pub’ [CWE-401] [-Wanalyzer-malloc-leak]
 1140 |         if (imaevm_params.x509)
      |            ^

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 src/evmctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/evmctl.c b/src/evmctl.c
index 4f55fb6..59a56c8 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1137,7 +1137,7 @@  static int cmd_import(struct command *cmd)
 		log_info("keyid: %d\n", id);
 		printf("%d\n", id);
 	}
-	if (imaevm_params.x509)
+	if (pub != _pub)
 		free(pub);
 	return err;
 }