Before importing a certificate, free any previous one. Bug 1648
[exim.git] / src / src / tlscert-gnu.c
index 40f49d36699dfd21a4d10a941cce65f90bbdc3bd..69ce27fc81db405b10edabf555966abe5f7081ea 100644 (file)
@@ -77,10 +77,15 @@ return fail;
 }
 
 void
-tls_free_cert(void * cert)
+tls_free_cert(void ** cert)
 {
-gnutls_x509_crt_deinit((gnutls_x509_crt_t) cert);
-gnutls_global_deinit();
+gnutls_x509_crt_t crt = *(gnutls_x509_crt_t *)cert;
+if (crt)
+  {
+  gnutls_x509_crt_deinit(crt);
+  gnutls_global_deinit();
+  *cert = NULL;
+  }
 }
 
 /*****************************************************