Fix memory leak in DNS manager (fixes #777).

This commit is contained in:
Jon Siwek 2012-02-20 11:56:21 -06:00
parent 52cfec8830
commit 1f7bfbb83c

View file

@ -704,6 +704,7 @@ void DNS_Mgr::AddResult(DNS_Mgr_Request* dr, struct nb_dns_result* r)
if ( dr->ReqHost() ) if ( dr->ReqHost() )
{ {
new_dm = new DNS_Mapping(dr->ReqHost(), h, ttl); new_dm = new DNS_Mapping(dr->ReqHost(), h, ttl);
prev_dm = 0;
HostMap::iterator it = host_mappings.find(dr->ReqHost()); HostMap::iterator it = host_mappings.find(dr->ReqHost());
if ( it == host_mappings.end() ) if ( it == host_mappings.end() )
@ -711,15 +712,11 @@ void DNS_Mgr::AddResult(DNS_Mgr_Request* dr, struct nb_dns_result* r)
host_mappings[dr->ReqHost()].first = host_mappings[dr->ReqHost()].first =
new_dm->Type() == AF_INET ? new_dm : 0; new_dm->Type() == AF_INET ? new_dm : 0;
host_mappings[dr->ReqHost()].second = host_mappings[dr->ReqHost()].second =
new_dm->Type() == AF_INET6 ? new_dm : 0; new_dm->Type() == AF_INET ? 0 : new_dm;
prev_dm = 0;
} }
else else
{ {
prev_dm = 0;
if ( new_dm->Type() == AF_INET ) if ( new_dm->Type() == AF_INET )
{ {
prev_dm = it->second.first; prev_dm = it->second.first;