From 3c2e689ae2a3eb33de8aad2b1e722a25fad8b6b8 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 24 May 2016 12:18:49 +0200 Subject: [PATCH] Index-out-of-bounds issue fixed --- lib/libZRCola/include/zrcola/common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libZRCola/include/zrcola/common.h b/lib/libZRCola/include/zrcola/common.h index 89418b6..8f7ad63 100644 --- a/lib/libZRCola/include/zrcola/common.h +++ b/lib/libZRCola/include/zrcola/common.h @@ -475,9 +475,10 @@ namespace ZRCola { inline int compare(_In_count_(key_len) const T_key *key, _In_ size_t key_len, size_type pos) const { // Get key at position pos. + size_type pos_next = pos + 1; size_t - start = base_t::at(pos ).idx_key, - key2_len = (pos < size() ? base_t::at(pos + 1).idx_key : keys.size()) - start; + start = base_t::at(pos ).idx_key, + key2_len = (pos_next < size() ? base_t::at(pos_next).idx_key : keys.size()) - start; std::vector::const_pointer key2 = &keys.at(start); // Compare keys.