]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 6 Feb 2017 14:37:20 +0000 (16:37 +0200)
src/lib-ssl-iostream/iostream-openssl-context.c

index 40d7c0efe63aa9f0bada9c32fadb864a9ec0ee7b..2065944d77969fc27446a2ed1157cddb6f413d58 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);