From: Remi Gacogne Date: Mon, 13 May 2019 09:17:39 +0000 (+0200) Subject: dnsdist: Don't let 'self' dangling while parsing the request's qname X-Git-Tag: rec-4.2.0-rc1~22^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=19642bff7c25f3c7d84c214121a217af142ab39d;p=pdns dnsdist: Don't let 'self' dangling while parsing the request's qname --- diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index 9b183e5f1..22c3765ca 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -279,16 +279,17 @@ static void on_generator_dispose(void *_self) static void doh_dispatch_query(DOHServerConfig* dsc, h2o_handler_t* self, h2o_req_t* req, std::string&& query, const ComboAddress& local, const ComboAddress& remote) { try { - auto du = std::unique_ptr(new DOHUnit); - du->self = reinterpret_cast(h2o_mem_alloc_shared(&req->pool, sizeof(*self), on_generator_dispose)); uint16_t qtype; DNSName qname(query.c_str(), query.size(), sizeof(dnsheader), false, &qtype); + + auto du = std::unique_ptr(new DOHUnit); du->req = req; - du->query = std::move(query); du->dest = local; du->remote = remote; du->rsock = dsc->dohresponsepair[0]; + du->query = std::move(query); du->qtype = qtype; + du->self = reinterpret_cast(h2o_mem_alloc_shared(&req->pool, sizeof(*self), on_generator_dispose)); auto ptr = du.release(); *(ptr->self) = ptr; try {