From e875acbdf5659ddc13bf47d50fb5ec7fbb171ec6 Mon Sep 17 00:00:00 2001 From: Daniel Salzman Date: Thu, 26 Aug 2021 08:20:06 +0200 Subject: [PATCH] kdig: fix double free when query times out fixes #763 --- src/utils/common/https.c | 1 + src/utils/common/netio.c | 4 ++++ src/utils/common/tls.c | 1 + 3 files changed, 6 insertions(+) diff --git a/src/utils/common/https.c b/src/utils/common/https.c index 73283a7e97..bc7912bfea 100644 --- a/src/utils/common/https.c +++ b/src/utils/common/https.c @@ -505,6 +505,7 @@ void https_ctx_deinit(https_ctx_t *ctx) } nghttp2_session_del(ctx->session); + ctx->session = NULL; pthread_mutex_destroy(&ctx->recv_mx); free(ctx->path); ctx->path = NULL; diff --git a/src/utils/common/netio.c b/src/utils/common/netio.c index 5528002f92..684989801b 100644 --- a/src/utils/common/netio.c +++ b/src/utils/common/netio.c @@ -659,6 +659,8 @@ void net_clean(net_t *net) free(net->local_str); free(net->remote_str); + net->local_str = NULL; + net->remote_str = NULL; if (net->local_info != NULL) { if (net->local == NULL) { @@ -666,10 +668,12 @@ void net_clean(net_t *net) } else { freeaddrinfo(net->local_info); } + net->local_info = NULL; } if (net->remote_info != NULL) { freeaddrinfo(net->remote_info); + net->remote_info = NULL; } #ifdef LIBNGHTTP2 diff --git a/src/utils/common/tls.c b/src/utils/common/tls.c index 1328927c5c..4c50bf8494 100644 --- a/src/utils/common/tls.c +++ b/src/utils/common/tls.c @@ -695,6 +695,7 @@ void tls_ctx_deinit(tls_ctx_t *ctx) if (ctx->credentials != NULL) { gnutls_certificate_free_credentials(ctx->credentials); + ctx->credentials = NULL; } } -- 2.47.3