diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-08-28 18:27:48 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-08-28 18:27:48 +0000 |
commit | 61ca876b03330d552c2f552bca9355c61db7dc00 (patch) | |
tree | 23bf045232fbacbe969664971377abd066078e07 | |
parent | fc1f2ca15fa635047e91df293eb025df4bfc2c99 (diff) |
Plug memory leak in CMS_add_simple_smimecap() in the unlikely event that
ASN1_INTEGER_set() fails.
ok jsing
-rw-r--r-- | lib/libcrypto/cms/cms_sd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libcrypto/cms/cms_sd.c b/lib/libcrypto/cms/cms_sd.c index 95343d08876..29dbfb2d19e 100644 --- a/lib/libcrypto/cms/cms_sd.c +++ b/lib/libcrypto/cms/cms_sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_sd.c,v 1.23 2019/08/11 14:35:57 jsing Exp $ */ +/* $OpenBSD: cms_sd.c,v 1.24 2022/08/28 18:27:47 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -955,9 +955,12 @@ CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, int algnid, int keysize) ASN1_INTEGER *key = NULL; if (keysize > 0) { - key = ASN1_INTEGER_new(); - if (key == NULL || !ASN1_INTEGER_set(key, keysize)) + if ((key = ASN1_INTEGER_new()) == NULL) return 0; + if (!ASN1_INTEGER_set(key, keysize)) { + ASN1_INTEGER_free(key); + return 0; + } } alg = X509_ALGOR_new(); if (alg == NULL) { |