Merge pull request #6285

d0641b42 net: fix incorrect less operator for top/i2p addresses (Aaron Hook)
This commit is contained in:
Alexander Blair 2020-03-27 12:23:00 -07:00
commit 7d4a93fab3
No known key found for this signature in database
GPG key ID: C64552D877C32479
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