From ed68d1ff287d43c5293abb4d41e908aa8e50afec Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Jul 2014 21:14:01 +0100 Subject: utf8: use end of sequence iterators for more security --- src/buffer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/buffer.cc') 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; } -- cgit v1.2.3