Fix potential misaligned ipv6 result records from DNS search
[exim.git] / src / src / tlscert-gnu.c
index 40f49d36699dfd21a4d10a941cce65f90bbdc3bd..d00258b9e250dcbe0734f2f8079a0a5941051ebb 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;
+  }
 }
 
 /*****************************************************
@@ -323,11 +328,11 @@ for(index = 0;; index++)
   switch (ret)
     {
     case GNUTLS_SAN_DNSNAME:    tag = US"DNS";  break;
-    case GNUTLS_SAN_URI:        tag = US"URI";  break; 
+    case GNUTLS_SAN_URI:        tag = US"URI";  break;
     case GNUTLS_SAN_RFC822NAME: tag = US"MAIL"; break;
     default: continue;        /* ignore unrecognised types */
     }
-  list = string_append_listele(list, sep, 
+  list = string_append_listele(list, sep,
           match == -1 ? string_sprintf("%s=%s", tag, ele) : ele);
   }
 /*NOTREACHED*/
@@ -363,7 +368,7 @@ for(index = 0;; index++)
 
 #else
 
-expand_string_message = 
+expand_string_message =
   string_sprintf("%s: OCSP support with GnuTLS requires version 3.0.0\n",
     __FUNCTION__);
 return NULL;