]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Use unique_ptr for `AuthLua` and `AuthLua4` objects
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 15 Sep 2016 09:12:58 +0000 (11:12 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 15 Sep 2016 09:12:58 +0000 (11:12 +0200)
Fix a leak reported by coverity when we cycle a backend.

pdns/lua-auth4.cc
pdns/packethandler.cc
pdns/packethandler.hh

index a6ff335f99198bec9f3bdf7db8cf7e53672b1799..4263b730ade6e2c255094eabff328cf8293fa31d 100644 (file)
@@ -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
index c4ad19bb5ab9fb009898625fec8ec3a0c348cbdf..610494f18a8d63af4b40998f5de0c1808bbd8587 100644 (file)
@@ -69,7 +69,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B)
   }
   else
   {
-    d_pdl = new AuthLua(fname);
+    d_pdl = std::unique_ptr<AuthLua>(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<AuthLua4>(new AuthLua4(fname));
   }
 }
 
index f3301fd26dc7b113028299e3b4ac9ecf54e49ae5..e422e413494c7636fb8d2f9f110bc456f90ec1ed 100644 (file)
@@ -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<AuthLua> d_pdl;
+  std::unique_ptr<AuthLua4> d_update_policy_lua;
 
   UeberBackend B; // every thread an own instance
   DNSSECKeeper d_dk; // B is shared with DNSSECKeeper