diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-07-02 21:14:01 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-07-05 12:10:06 +0100 |
| commit | ed68d1ff287d43c5293abb4d41e908aa8e50afec (patch) | |
| tree | b5ab042ba67259a63b2aa0ae99ad74a5bc646a7f /src/selectors.cc | |
| parent | 3f70d91f8c716ef2dbc76abb9c878f86ecb946f7 (diff) | |
utf8: use end of sequence iterators for more security
Diffstat (limited to 'src/selectors.cc')
| -rw-r--r-- | src/selectors.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/selectors.cc b/src/selectors.cc index b2b08073..7c05bc36 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -494,7 +494,7 @@ void select_all_matches(SelectionList& selections, const Regex& regex) auto& buffer = selections.buffer(); for (auto& sel : selections) { - auto sel_end = utf8::next(buffer.iterator_at(sel.max())); + auto sel_end = utf8::next(buffer.iterator_at(sel.max()), buffer.end()); RegexIterator re_it(buffer.iterator_at(sel.min()), sel_end, regex); RegexIterator re_end; @@ -511,7 +511,7 @@ void select_all_matches(SelectionList& selections, const Regex& regex) captures.emplace_back(match.first, match.second); result.push_back({ begin.coord(), - (begin == end ? end : utf8::previous(end)).coord(), + (begin == end ? end : utf8::previous(end, begin)).coord(), std::move(captures) }); } } @@ -527,7 +527,7 @@ void split_selections(SelectionList& selections, const Regex& regex) for (auto& sel : selections) { auto begin = buffer.iterator_at(sel.min()); - auto sel_end = utf8::next(buffer.iterator_at(sel.max())); + auto sel_end = utf8::next(buffer.iterator_at(sel.max()), buffer.end()); RegexIterator re_it(begin, sel_end, regex, boost::regex_constants::match_nosubs); RegexIterator re_end; @@ -536,7 +536,7 @@ void split_selections(SelectionList& selections, const Regex& regex) { BufferIterator end = (*re_it)[0].first; - result.push_back({ begin.coord(), (begin == end) ? end.coord() : utf8::previous(end).coord() }); + result.push_back({ begin.coord(), (begin == end) ? end.coord() : utf8::previous(end, begin).coord() }); begin = (*re_it)[0].second; } if (begin.coord() <= sel.max()) |
