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

1
NEWS
View File

@@ -2,6 +2,7 @@ ncmpcpp-0.7.5 (????-??-??)
* Action chains can be now used for seeking.
* Fixed fetching artist info from last.fm.
* Default value of regular_expressions was changed from 'basic' to 'perl' to work around boost issue (#12222).
* Fixed crash occuring when searching backward in an empty list.
ncmpcpp 0.7.4 (2016-04-17)
* Fetching lyrics from lyricwiki.org was fixed.

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);