fix memory leak/bug in torrent::use_interface

This commit is contained in:
Arvid Norberg 2012-05-03 04:22:14 +00:00
parent cf49986e1a
commit 56c05f9671
1 changed files with 8 additions and 7 deletions

View File

@ -2068,14 +2068,15 @@ namespace libtorrent
m_net_interfaces.clear();
char* str = strdup(net_interfaces.c_str());
char* ptr = str;
while (str)
while (ptr)
{
char* space = strchr(str, ',');
char* space = strchr(ptr, ',');
if (space) *space++ = 0;
error_code ec;
address a(address::from_string(str, ec));
str = space;
address a(address::from_string(ptr, ec));
ptr = space;
if (ec) continue;
m_net_interfaces.push_back(tcp::endpoint(a, 0));
}
@ -5833,9 +5834,9 @@ namespace libtorrent
for (std::set<peer_connection*>::iterator i = m_connections.begin()
, end(m_connections.end()); i != end; ++i)
{
peer_connection* p = *i;
if (!p->is_connecting()) continue;
p->disconnect(errors::too_many_connections);
peer_connection* peer = *i;
if (!peer->is_connecting()) continue;
peer->disconnect(errors::too_many_connections);
break;
}
}