]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk.c: Fix memory leak in ephemeral certificate creation.
authorSean Bright <sean@seanbright.com>
Wed, 25 Oct 2023 22:19:13 +0000 (18:19 -0400)
committerAsterisk Development Team <asteriskteam@digium.com>
Fri, 12 Jan 2024 18:32:12 +0000 (18:32 +0000)
Fixes #386

(cherry picked from commit 74a5c452de6f78e3182c65603cb8c27fe1287b92)

res/res_rtp_asterisk.c

index 8bfa2711b8477f93f2f971272c8624bce24cb9ab..c641641bbff252ce53d8f1a4a2b1606c67f54619 100644 (file)
@@ -2029,9 +2029,12 @@ static int create_ephemeral_certificate(EVP_PKEY *keypair, X509 **certificate)
        if (!(serial = BN_new())
           || !BN_rand(serial, SERIAL_RAND_BITS, -1, 0)
           || !BN_to_ASN1_INTEGER(serial, X509_get_serialNumber(cert))) {
+               BN_free(serial);
                goto error;
        }
 
+       BN_free(serial);
+
        /*
         * Validity period - Current Chrome & Firefox make it 31 days starting
         * with yesterday at the current time, so we will do the same.
@@ -2066,7 +2069,6 @@ static int create_ephemeral_certificate(EVP_PKEY *keypair, X509 **certificate)
        return 0;
 
 error:
-       BN_free(serial);
        X509_free(cert);
 
        return -1;