]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Fix memory leak in RSA_generate_key_ex() usage
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 6 Feb 2017 09:02:46 +0000 (11:02 +0200)
committerGitLab <gitlab@git.dovecot.net>
Mon, 6 Feb 2017 10:24:28 +0000 (12:24 +0200)
src/lib-ssl-iostream/iostream-openssl-context.c

index b97009c80f5a589164f7f1267ba5e1664637772e..31d81bdf0c39a9a03050fc84655f0c71899f52f8 100644 (file)
@@ -34,8 +34,10 @@ static RSA *ssl_gen_rsa_key(SSL *ssl ATTR_UNUSED,
        RSA *rsa = RSA_new();
 
        if (bn != NULL && BN_set_word(bn, RSA_F4) != 0 &&
-           RSA_generate_key_ex(rsa, keylength, bn, NULL) != 0)
+           RSA_generate_key_ex(rsa, keylength, bn, NULL) != 0) {
+               BN_free(bn);
                return rsa;
+       }
 
        if (bn != NULL)
                BN_free(bn);