BIND 10 master, updated. 0cfe92d0076a6b8108cb232a5fbfddddd9197c0b fix: memory leak in IfaceMgr::receive4(), reference in IfaceMgr test (cppcheck)

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Dec 29 13:19:04 UTC 2011


The branch, master has been updated
       via  0cfe92d0076a6b8108cb232a5fbfddddd9197c0b (commit)
      from  56f15f53c14593d5a6c777cee0567e92c8cab23f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0cfe92d0076a6b8108cb232a5fbfddddd9197c0b
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Thu Dec 29 14:18:02 2011 +0100

    fix: memory leak in IfaceMgr::receive4(), reference in IfaceMgr test (cppcheck)

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcp/iface_mgr.cc                |    4 +---
 src/lib/dhcp/tests/iface_mgr_unittest.cc |    2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc
index dfdeecb..153ffda 100644
--- a/src/lib/dhcp/iface_mgr.cc
+++ b/src/lib/dhcp/iface_mgr.cc
@@ -716,7 +716,7 @@ IfaceMgr::receive4() {
     struct in_addr to_addr;
     boost::shared_ptr<Pkt4> pkt;
     const uint32_t RCVBUFSIZE = 1500;
-    uint8_t* buf = (uint8_t*) malloc(RCVBUFSIZE);
+    static uint8_t buf[RCVBUFSIZE];
 
     memset(&control_buf_[0], 0, control_buf_len_);
     memset(&from_addr, 0, sizeof(from_addr));
@@ -747,7 +747,6 @@ IfaceMgr::receive4() {
 
     if (result < 0) {
         cout << "Failed to receive UDP4 data." << endl;
-        delete buf;
         return (boost::shared_ptr<Pkt4>()); // NULL
     }
 
@@ -784,7 +783,6 @@ IfaceMgr::receive4() {
     }
     if (!found_pktinfo) {
         cout << "Unable to find pktinfo" << endl;
-        delete buf;
         return (boost::shared_ptr<Pkt4>()); // NULL
     }
 #endif
diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc
index ce63945..ee0769d 100644
--- a/src/lib/dhcp/tests/iface_mgr_unittest.cc
+++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc
@@ -675,7 +675,7 @@ size_t parse_mac(const std::string& textMac, uint8_t* mac, size_t macLen) {
 ///
 /// @param textFile name of a text file that holds output of ifconfig -a
 /// @param ifaces empty list of interfaces to be filled
-void parse_ifconfig(const std::string textFile, IfaceMgr::IfaceCollection& ifaces) {
+void parse_ifconfig(const std::string& textFile, IfaceMgr::IfaceCollection& ifaces) {
     fstream f(textFile.c_str());
 
     bool first_line = true;




More information about the bind10-changes mailing list