net: fix incorrect less operator for top/i2p addresses

This commit is contained in:
Aaron Hook 2020-01-18 19:18:56 -08:00
parent 51873fec04
commit d0641b42fe
3 changed files with 406 additions and 24 deletions

View file

@ -171,7 +171,8 @@ namespace net
bool i2p_address::less(const i2p_address& rhs) const noexcept
{
return std::strcmp(host_str(), rhs.host_str()) < 0 || port() < rhs.port();
int res = std::strcmp(host_str(), rhs.host_str());
return res < 0 || (res == 0 && port() < rhs.port());
}
bool i2p_address::is_same_host(const i2p_address& rhs) const noexcept

View file

@ -173,7 +173,8 @@ namespace net
bool tor_address::less(const tor_address& rhs) const noexcept
{
return std::strcmp(host_str(), rhs.host_str()) < 0 || port() < rhs.port();
int res = std::strcmp(host_str(), rhs.host_str());
return res < 0 || (res == 0 && port() < rhs.port());
}
bool tor_address::is_same_host(const tor_address& rhs) const noexcept