From: tb Date: Sun, 28 Aug 2022 18:27:47 +0000 (+0000) Subject: Plug memory leak in CMS_add_simple_smimecap() in the unlikely event that X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=364a61ebcb8024d0d4c9741d699a9fabe049ef99;p=openbsd Plug memory leak in CMS_add_simple_smimecap() in the unlikely event that ASN1_INTEGER_set() fails. ok jsing --- 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) {