diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-09-28 16:13:59 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-09-28 16:13:59 -0700 |
commit | 4fe9a4fe8376237ffba684a3e0be2edb14527fe1 (patch) | |
tree | ed1c8562167fc51b68542d4781bae8e659cfb695 /node | |
parent | 01129d02b3863f92c0f94b29e9600153b743f967 (diff) | |
download | infinitytier-4fe9a4fe8376237ffba684a3e0be2edb14527fe1.tar.gz infinitytier-4fe9a4fe8376237ffba684a3e0be2edb14527fe1.zip |
Fix memory leak.
Diffstat (limited to 'node')
-rw-r--r-- | node/Network.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/node/Network.cpp b/node/Network.cpp index 52abbcf9..ac679e46 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -993,12 +993,11 @@ uint64_t Network::handleConfigChunk(const Packet &chunk,unsigned int ptr) try { if (nc->fromDictionary(c->data)) { this->_setConfiguration(*nc,true); + delete nc; return configUpdateId; } - delete nc; - } catch ( ... ) { - delete nc; - } + } catch ( ... ) {} + delete nc; } return 0; @@ -1025,25 +1024,31 @@ void Network::requestConfiguration() if (ctrl == RR->identity.address()) { if (RR->localNetworkController) { - NetworkConfig nconf; - switch(RR->localNetworkController->doNetworkConfigRequest(InetAddress(),RR->identity,RR->identity,_id,rmd,nconf)) { - case NetworkController::NETCONF_QUERY_OK: { - Mutex::Lock _l(_lock); - this->_setConfiguration(nconf,true); - } return; - case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND: - this->setNotFound(); - return; - case NetworkController::NETCONF_QUERY_ACCESS_DENIED: - this->setAccessDenied(); - return; - default: - return; + NetworkConfig *nconf = new NetworkConfig(); + try { + switch(RR->localNetworkController->doNetworkConfigRequest(InetAddress(),RR->identity,RR->identity,_id,rmd,*nconf)) { + case NetworkController::NETCONF_QUERY_OK: { + Mutex::Lock _l(_lock); + this->_setConfiguration(*nconf,true); + } break; + case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND: + this->setNotFound(); + break; + case NetworkController::NETCONF_QUERY_ACCESS_DENIED: + this->setAccessDenied(); + break; + default: + this->setNotFound(); + break; + } + } catch ( ... ) { + this->setNotFound(); } + delete nconf; } else { this->setNotFound(); - return; } + return; } TRACE("requesting netconf for network %.16llx from controller %s",(unsigned long long)_id,ctrl.toString().c_str()); |