From c826633442b5372879ca3eb9f742baf6b4f8e284 Mon Sep 17 00:00:00 2001
From: kaldoran <kaldoran@live.fr>
Date: Mon, 25 Jul 2016 19:05:09 -0400
Subject: [PATCH] Correction of error on SwapBit

---
 include/opendht/indexation/pht.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/opendht/indexation/pht.h b/include/opendht/indexation/pht.h
index 85d79b4b..7d1e5e64 100644
--- a/include/opendht/indexation/pht.h
+++ b/include/opendht/indexation/pht.h
@@ -124,7 +124,7 @@ struct Prefix {
      * @throw out_of_range Throw out of range if bit does not exist
      */
     Prefix swapBit(size_t bit) const {
-        if ( bit >= size_ )
+        if ( bit >= content_.size() * 8 )
             throw std::out_of_range("bit larger than prefix size.");
 
         Prefix copy = *this;
@@ -261,7 +261,7 @@ private:
         Prefix p = Blob {k.begin()->second.begin(), k.begin()->second.end()};
 
         auto bit_loc = p.size_ + 1;
-        for ( auto i = p.content_.size(); i <= keySpec_.begin()->second; i++ )
+        for ( auto i = p.content_.size(); i < keySpec_.begin()->second + 1; i++ )
             p.content_.push_back(0);
 
         return p.swapBit(bit_loc);
-- 
GitLab