dht: Make i_partitioner::tri_compare memory safe

This patch fixes a typo in i_partitioner::tri_compare() where we were
using std::max instead of std::min, thus avoiding accessing random
memory and getting random results.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
Message-Id: <20161211165043.17816-1-duarte@scylladb.com>
This commit is contained in:
Duarte Nunes
2016-12-11 17:50:43 +01:00
committed by Avi Kivity
parent 299d1fad0b
commit bb66b051ed

View File

@@ -113,7 +113,7 @@ static inline unsigned char get_byte(bytes_view b, size_t off) {
}
int i_partitioner::tri_compare(const token& t1, const token& t2) const {
size_t sz = std::max(t1._data.size(), t2._data.size());
size_t sz = std::min(t1._data.size(), t2._data.size());
for (size_t i = 0; i < sz; i++) {
auto b1 = get_byte(t1._data, i);