Fix crash occuring when searching backward in an empty list

This commit is contained in:
Andrzej Rybczak
2016-08-17 17:27:16 +02:00
parent 0465962409
commit e657089b30
2 changed files with 6 additions and 0 deletions

View File

@@ -35,6 +35,11 @@ template <typename Iterator, typename PredicateT>
Iterator wrappedSearch(Iterator begin, Iterator current, Iterator end,
const PredicateT &pred, bool wrap, bool skip_current)
{
if (begin == end)
{
assert(current == end);
return begin;
}
if (skip_current)
++current;
auto it = std::find_if(current, end, pred);