diff options
author | Peiwei Hu <jlu.hpw@foxmail.com> | 2021-12-15 16:24:21 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-12-17 15:10:06 +0100 |
commit | c81eed84e4e9025e933778f5e8326b1e4435e094 (patch) | |
tree | 77ccb532d9c10faf874adb59a8e4dd75d9701323 /demos/cms | |
parent | ec9135a62320c861ab17f7179ebe470686360c64 (diff) |
X509_STORE_new: memory needs to be freed
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17278)
Diffstat (limited to 'demos/cms')
-rw-r--r-- | demos/cms/cms_ver.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/demos/cms/cms_ver.c b/demos/cms/cms_ver.c index cd2b01e1b0..3c0a7aa19e 100644 --- a/demos/cms/cms_ver.c +++ b/demos/cms/cms_ver.c @@ -27,16 +27,18 @@ int main(int argc, char **argv) /* Set up trusted CA certificate store */ st = X509_STORE_new(); + if (st == NULL) + goto err; /* Read in CA certificate */ tbio = BIO_new_file("cacert.pem", "r"); - if (!tbio) + if (tbio == NULL) goto err; cacert = PEM_read_bio_X509(tbio, NULL, 0, NULL); - if (!cacert) + if (cacert == NULL) goto err; if (!X509_STORE_add_cert(st, cacert)) @@ -46,18 +48,18 @@ int main(int argc, char **argv) in = BIO_new_file("smout.txt", "r"); - if (!in) + if (in == NULL) goto err; /* parse message */ cms = SMIME_read_CMS(in, &cont); - if (!cms) + if (cms == NULL) goto err; /* File to output verified content to */ out = BIO_new_file("smver.txt", "w"); - if (!out) + if (out == NULL) goto err; if (!CMS_verify(cms, NULL, st, cont, out, 0)) { @@ -76,6 +78,7 @@ int main(int argc, char **argv) ERR_print_errors_fp(stderr); } + X509_STORE_free(st); CMS_ContentInfo_free(cms); X509_free(cacert); BIO_free(in); |