From 65f4fbbc81b799d324f486b8294cd08166f92fc7 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Fri, 14 Dec 2018 15:38:32 +0000 Subject: [PATCH] Make sure all connection deinits are only called if there is something to deinit. --- src/gnutls/tls.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gnutls/tls.c b/src/gnutls/tls.c index b2ea8e91..a9e96241 100644 --- a/src/gnutls/tls.c +++ b/src/gnutls/tls.c @@ -248,6 +248,7 @@ _getdns_tls_connection* _getdns_tls_connection_new(struct mem_funcs* mfs, _getdn res->shutdown = 0; res->ctx = ctx; res->mfs = mfs; + res->cred = NULL; res->tls = NULL; res->cipher_list = NULL; res->curve_list = NULL; @@ -295,7 +296,8 @@ getdns_return_t _getdns_tls_connection_free(struct mem_funcs* mfs, _getdns_tls_c dane_state_deinit(conn->dane_state); if (conn->tls) gnutls_deinit(conn->tls); - gnutls_certificate_free_credentials(conn->cred); + if (conn->cred) + gnutls_certificate_free_credentials(conn->cred); GETDNS_FREE(*mfs, conn->tlsa); GETDNS_FREE(*mfs, conn->curve_list); GETDNS_FREE(*mfs, conn->cipher_list);