mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
Pht : Fix out of range in isActiveBit function
This commit is contained in:
1 parent
d2ccde4859
commit
95aef01a59
1 file changed
+4
@@ -52,8 +52,12 @@ struct Prefix {
|
||||
* @param pos : Pos of the needed bit
|
||||
* @return : true if the bit is at 1
|
||||
* false otherwise
|
||||
* @throw out_of_range Throw out of range if the bit at 'pos' does not exist
|
||||
*/
|
||||
bool isActiveBit(size_t pos) const {
|
||||
if ( pos >= size_ )
|
||||
throw std::out_of_range("Can't detect active bit at pos, pos larger than prefix size or empty prefix");
|
||||
|
||||
return ((this->content_[pos / 8] >> (7 - (pos % 8)) ) & 1) == 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user