From: Remi Gacogne Date: Thu, 15 Sep 2016 09:12:58 +0000 (+0200) Subject: auth: Use unique_ptr for `AuthLua` and `AuthLua4` objects X-Git-Tag: dnsdist-1.1.0-beta2~111^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ce6361c7fa19dc97109965eabcbb31bb9415ae8;p=thirdparty%2Fpdns.git auth: Use unique_ptr for `AuthLua` and `AuthLua4` objects Fix a leak reported by coverity when we cycle a backend. --- diff --git a/pdns/lua-auth4.cc b/pdns/lua-auth4.cc index a6ff335f99..4263b730ad 100644 --- a/pdns/lua-auth4.cc +++ b/pdns/lua-auth4.cc @@ -11,6 +11,7 @@ AuthLua4::AuthLua4(const std::string& fname) { } bool AuthLua4::updatePolicy(const DNSName &qname, QType qtype, const DNSName &zonename, DNSPacket *packet) { return false; } +AuthLua4::~AuthLua4() { } #else @@ -238,4 +239,6 @@ bool AuthLua4::updatePolicy(const DNSName &qname, QType qtype, const DNSName &zo return d_update_policy(upq); } +AuthLua4::~AuthLua4() { } + #endif diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index c4ad19bb5a..610494f18a 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -69,7 +69,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B) } else { - d_pdl = new AuthLua(fname); + d_pdl = std::unique_ptr(new AuthLua(fname)); } fname = ::arg()["lua-dnsupdate-policy-script"]; if (fname.empty()) @@ -78,7 +78,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B) } else { - d_update_policy_lua = new AuthLua4(fname); + d_update_policy_lua = std::unique_ptr(new AuthLua4(fname)); } } diff --git a/pdns/packethandler.hh b/pdns/packethandler.hh index f3301fd26d..e422e41349 100644 --- a/pdns/packethandler.hh +++ b/pdns/packethandler.hh @@ -109,8 +109,8 @@ private: bool d_logDNSDetails; bool d_doIPv6AdditionalProcessing; bool d_doDNAME; - AuthLua* d_pdl; - AuthLua4* d_update_policy_lua; + std::unique_ptr d_pdl; + std::unique_ptr d_update_policy_lua; UeberBackend B; // every thread an own instance DNSSECKeeper d_dk; // B is shared with DNSSECKeeper