From 6a9681e90c08461c3bee4549985bb550ddf6c275 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 10 May 2016 20:28:08 +0300 Subject: [PATCH] OpenSSL: Make dh5_init() match the generic implementation Commit 4104267e81b0a0acdb43f693a67f236b3237a719 ('Fix memory leak on NFC DH generation error path') modified the generic (non-OpenSSL) implementation of dh5_init() to free the previously assigned public key, if any. However, that commit did not modify the OpenSSL specific version of this function. Add the same change there to maintain consistent behavior between these two implementations of the same function. Signed-off-by: Jouni Malinen --- src/crypto/crypto_openssl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 28ebc0b38..dadd30ea6 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -608,6 +608,7 @@ void * dh5_init(struct wpabuf **priv, struct wpabuf **publ) size_t publen, privlen; *priv = NULL; + wpabuf_free(*publ); *publ = NULL; dh = DH_new(); @@ -653,6 +654,7 @@ err: BIGNUM *p = NULL, *g, *priv_key = NULL, *pub_key = NULL; *priv = NULL; + wpabuf_free(*publ); *publ = NULL; dh = DH_new();