From 08bf613cde3e44088bbcc6916f5a40b1d1defe34 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Sun, 15 Nov 2015 12:46:21 -0500 Subject: [PATCH] Prevent segfault with failed TLS handshake? Need proper review for this patch! Sara? --- src/stub.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stub.c b/src/stub.c index e4689535c..c0c254cc9 100644 --- a/src/stub.c +++ b/src/stub.c @@ -1501,9 +1501,15 @@ upstream_write_cb(void *userarg) { getdns_upstream *upstream = (getdns_upstream *)userarg; getdns_network_req *netreq = upstream->write_queue; - getdns_dns_req *dnsreq = netreq->owner; + getdns_dns_req *dnsreq; int q; + if (!netreq) { + GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event); + upstream->event.write_cb = NULL; + return; + } + dnsreq = netreq->owner; /* TODO: think about TCP AGAIN */ netreq->debug_start_time = _getdns_get_time_as_uintt64();