summaryrefslogtreecommitdiff
path: root/src/selectors.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-07-02 21:14:01 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-07-05 12:10:06 +0100
commited68d1ff287d43c5293abb4d41e908aa8e50afec (patch)
treeb5ab042ba67259a63b2aa0ae99ad74a5bc646a7f /src/selectors.hh
parent3f70d91f8c716ef2dbc76abb9c878f86ecb946f7 (diff)
utf8: use end of sequence iterators for more security
Diffstat (limited to 'src/selectors.hh')
-rw-r--r--src/selectors.hh6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/selectors.hh b/src/selectors.hh
index 5471a5c9..191a15dc 100644
--- a/src/selectors.hh
+++ b/src/selectors.hh
@@ -50,7 +50,7 @@ inline void remove_selection(SelectionList& selections, int index)
selections.check_invariant();
}
-using Utf8Iterator = utf8::iterator<BufferIterator, utf8::InvalidBytePolicy::Pass>;
+using Utf8Iterator = utf8::iterator<BufferIterator, utf8::InvalidPolicy::Pass>;
inline Selection utf8_range(const Utf8Iterator& first, const Utf8Iterator& last)
{
@@ -265,7 +265,7 @@ Selection find_next_match(const Buffer& buffer, const Selection& sel, const Rege
CaptureList captures;
MatchResults matches;
bool found = false;
- if ((found = find_match_in_buffer<direction>(buffer, utf8::next(begin), matches, regex)))
+ if ((found = find_match_in_buffer<direction>(buffer, utf8::next(begin, buffer.end()), matches, regex)))
{
begin = matches[0].first;
end = matches[0].second;
@@ -275,7 +275,7 @@ Selection find_next_match(const Buffer& buffer, const Selection& sel, const Rege
if (not found or begin == buffer.end())
throw runtime_error("'" + regex.str() + "': no matches found");
- end = (begin == end) ? end : utf8::previous(end);
+ end = (begin == end) ? end : utf8::previous(end, begin);
if (direction == Backward)
std::swap(begin, end);