From cc0a813f23136fb1f1aff8bf4cdc831ae3d360d4 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Sat, 18 Feb 2017 20:43:01 +0300 Subject: [PATCH] Fix memory leak in pkcs12 -export Reviewed-by: Andy Polyakov Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/2676) (cherry picked from commit 1b8f19379a521ec11ce37e12316dd3edc0acfb82) --- crypto/pkcs12/p12_mutl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index d6b891920c..899a12e134 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -204,6 +204,9 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, { X509_ALGOR *macalg; + PKCS12_MAC_DATA_free(p12->mac); + p12->mac = NULL; + if ((p12->mac = PKCS12_MAC_DATA_new()) == NULL) return PKCS12_ERROR; if (iter > 1) { -- 2.25.1