changeset 21492:c0f9d3f9bfd0

lib-ssl-iostream: Fix memory leak in RSA_generate_key_ex() usage
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 06 Feb 2017 11:02:46 +0200
parents c130a08ebbaf
children f2d8b1c3773e
files src/lib-ssl-iostream/iostream-openssl-context.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-ssl-iostream/iostream-openssl-context.c	Mon Feb 06 11:23:50 2017 +0200
+++ b/src/lib-ssl-iostream/iostream-openssl-context.c	Mon Feb 06 11:02:46 2017 +0200
@@ -34,8 +34,10 @@
 	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);