summaryrefslogtreecommitdiff
path: root/apps/verify.c
diff options
context:
space:
mode:
authorPaul Yang <yang.yang@baishancloud.com>2019-03-13 18:04:05 +0800
committerPaul Yang <yang.yang@baishancloud.com>2019-03-30 08:31:26 +0900
commit875c9a9a342383b3c3fd74a5c872bbf3fe9cdbd3 (patch)
tree9d8832ab60c17b76ce53e03dd550cd7b06fc2795 /apps/verify.c
parent7eba43e837eb3669d6b32d4ba27c3e93db29b8c3 (diff)
downloadopenssl-new-875c9a9a342383b3c3fd74a5c872bbf3fe9cdbd3.tar.gz
Fix a memleak in apps/verify
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8465)
Diffstat (limited to 'apps/verify.c')
-rw-r--r--apps/verify.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/apps/verify.c b/apps/verify.c
index fcd10dd9af..67d3276226 100644
--- a/apps/verify.c
+++ b/apps/verify.c
@@ -80,6 +80,7 @@ int verify_main(int argc, char **argv)
OPTION_CHOICE o;
unsigned char *sm2_id = NULL;
size_t sm2_idlen = 0;
+ int sm2_free = 0;
if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
goto end;
@@ -174,6 +175,7 @@ int verify_main(int argc, char **argv)
break;
case OPT_SM2HEXID:
/* try to parse the input as hex string first */
+ sm2_free = 1;
sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen);
if (sm2_id == NULL) {
BIO_printf(bio_err, "Invalid hex string input\n");
@@ -216,6 +218,8 @@ int verify_main(int argc, char **argv)
}
end:
+ if (sm2_free)
+ OPENSSL_free(sm2_id);
X509_VERIFY_PARAM_free(vpm);
X509_STORE_free(store);
sk_X509_pop_free(untrusted, X509_free);