From: Remi Gacogne Date: Fri, 7 Jul 2017 16:56:17 +0000 (+0200) Subject: Wrap the dynamic FD array into a unique_ptr in Resolver::tryGetSOASerial X-Git-Tag: dnsdist-1.2.0~52^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c9019674fb2228d23c1302b642cd5c68d0a7032;p=pdns Wrap the dynamic FD array into a unique_ptr in Resolver::tryGetSOASerial --- diff --git a/pdns/resolver.cc b/pdns/resolver.cc index 81a3126ec..86b224543 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -217,7 +217,7 @@ static int parseResult(MOADNSParser& mdp, const DNSName& origQname, uint16_t ori bool Resolver::tryGetSOASerial(DNSName *domain, uint32_t *theirSerial, uint32_t *theirInception, uint32_t *theirExpire, uint16_t* id) { - struct pollfd *fds = new struct pollfd[locals.size()]; + auto fds = std::unique_ptr(new struct pollfd[locals.size()]); size_t i = 0, k; int sock; @@ -226,8 +226,7 @@ bool Resolver::tryGetSOASerial(DNSName *domain, uint32_t *theirSerial, uint32_t fds[i].events = POLLIN; } - if (poll(fds, i, 250) < 1) { // wait for 0.25s - delete [] fds; + if (poll(fds.get(), i, 250) < 1) { // wait for 0.25s return false; } @@ -241,8 +240,6 @@ bool Resolver::tryGetSOASerial(DNSName *domain, uint32_t *theirSerial, uint32_t } } - delete [] fds; - if (sock < 0) return false; // false alarm int err;