]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk.c: Fix off nominal memory leak. 45/4645/1
authorRichard Mudgett <rmudgett@digium.com>
Wed, 7 Dec 2016 21:23:02 +0000 (15:23 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 21 Dec 2016 17:14:04 +0000 (11:14 -0600)
Change-Id: I95b1088d11244a2edae6607c12fbf33b38658a75

res/res_rtp_asterisk.c

index 64b13722f4117b1c02f5f903bf3a19f20c3d2589..1ae18fed3500c6743c7656287abe90a788c6406f 100644 (file)
@@ -1455,12 +1455,6 @@ static int ast_rtp_dtls_set_configuration(struct ast_rtp_instance *instance, con
                        return -1;
                }
 
-               if (!(certbio = BIO_new(BIO_s_file()))) {
-                       ast_log(LOG_ERROR, "Failed to allocate memory for certificate fingerprinting on RTP instance '%p'\n",
-                               instance);
-                       return -1;
-               }
-
                if (rtp->local_hash == AST_RTP_DTLS_HASH_SHA1) {
                        type = EVP_sha1();
                } else if (rtp->local_hash == AST_RTP_DTLS_HASH_SHA256) {
@@ -1471,6 +1465,12 @@ static int ast_rtp_dtls_set_configuration(struct ast_rtp_instance *instance, con
                        return -1;
                }
 
+               if (!(certbio = BIO_new(BIO_s_file()))) {
+                       ast_log(LOG_ERROR, "Failed to allocate memory for certificate fingerprinting on RTP instance '%p'\n",
+                               instance);
+                       return -1;
+               }
+
                if (!BIO_read_filename(certbio, dtls_cfg->certfile) ||
                    !(cert = PEM_read_bio_X509(certbio, NULL, 0, NULL)) ||
                    !X509_digest(cert, type, fingerprint, &size) ||