Fix memory leak.

This commit is contained in:
Adam Ierymenko 2016-09-28 16:13:59 -07:00
parent 01129d02b3
commit 4fe9a4fe83

View File

@ -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;
}
} 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)) {
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);
} return;
this->_setConfiguration(*nconf,true);
} break;
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND:
this->setNotFound();
return;
break;
case NetworkController::NETCONF_QUERY_ACCESS_DENIED:
this->setAccessDenied();
return;
break;
default:
return;
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());