]> granicus.if.org Git - pdns/commitdiff
dnsdist: Don't let 'self' dangling while parsing the request's qname
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 May 2019 09:17:39 +0000 (11:17 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 May 2019 09:17:39 +0000 (11:17 +0200)
pdns/dnsdistdist/doh.cc

index 9b183e5f151470f8b979f7d0f72a9321232c89eb..22c3765ca83a85547ed97261b1fea7020e186184 100644 (file)
@@ -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<DOHUnit>(new DOHUnit);
-    du->self = reinterpret_cast<DOHUnit**>(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<DOHUnit>(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<DOHUnit**>(h2o_mem_alloc_shared(&req->pool, sizeof(*self), on_generator_dispose));
     auto ptr = du.release();
     *(ptr->self) = ptr;
     try  {