Skip to content

Commit

Permalink
Fixed a rare indexing bug in CSSortedVector.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbnolok committed Oct 7, 2023
1 parent d99b6a7 commit 3d2d8ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/sphere_library/CSSortedVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ size_t CSSortedVector<_Type, _Comp>::binary_search_predicate(size_t _hi, _ValTyp
template <class _Type, class _Comp>
size_t CSSortedVector<_Type, _Comp>::find(_Type const& value) const noexcept
{
const size_t _mySize = this->size();
if (_mySize == 0) {
if (this->size() == 0) {
return SCONT_BADINDEX;
}
const size_t _mySize = this->size() - 1;
const _Type* const _dataptr = this->data();
const size_t _idx = this->lower_element(_mySize, _dataptr, value);
return (!this->_comparatorObj(value, _dataptr[_idx])) ? _idx : SCONT_BADINDEX;
Expand Down

0 comments on commit 3d2d8ba

Please sign in to comment.