Before importing a certificate, free any previous one. Bug 1648
[exim.git] / src / src / tlscert-openssl.c
index 165a3cf5c01ebd0c1741ebe38cec3f00fc0b8525..f2e482ba7757634413603b9859882365d6b5c423 100644 (file)
@@ -55,9 +55,11 @@ tls_import_cert(const uschar * buf, void ** cert)
 void * reset_point = store_get(0);
 const uschar * cp = string_unprinting(US buf);
 BIO * bp;
-X509 * x;
+X509 * x = *(X509 **)cert;
 int fail = 0;
 
+if (x) X509_free(x);
+
 bp = BIO_new_mem_buf(US cp, -1);
 if (!(x = PEM_read_bio_X509(bp, NULL, 0, NULL)))
   {