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/buffer.cc | |
| parent | 3f70d91f8c716ef2dbc76abb9c878f86ecb946f7 (diff) | |
utf8: use end of sequence iterators for more security
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index c9293a98..c41d7e8a 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -452,7 +452,7 @@ ByteCoord Buffer::char_next(ByteCoord coord) const if (coord.column < m_lines[coord.line].length() - 1) { auto& line = m_lines[coord.line]; - coord.column += utf8::codepoint_size(line.begin() + (int)coord.column); + coord.column += utf8::codepoint_size(line[(int)coord.column]); // Handle invalid utf-8 if (coord.column >= line.length()) { @@ -483,7 +483,7 @@ ByteCoord Buffer::char_prev(ByteCoord coord) const else { auto& line = m_lines[coord.line]; - coord.column = (int)(utf8::character_start(line.begin() + (int)coord.column - 1) - line.begin()); + coord.column = (int)(utf8::character_start(line.begin() + (int)coord.column - 1, line.begin()) - line.begin()); } return coord; } |
