From 7bc73b7ef9402f81a6bb496b03ba84197f76e642 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 13 May 2014 18:59:22 +0100 Subject: [PATCH] negative coordinates are invalid --- src/buffer.inl.hh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/buffer.inl.hh b/src/buffer.inl.hh index 9cfa2d0f..5375d993 100644 --- a/src/buffer.inl.hh +++ b/src/buffer.inl.hh @@ -52,6 +52,9 @@ inline ByteCount Buffer::offset(ByteCoord c) const inline bool Buffer::is_valid(ByteCoord c) const { + if (c.line < 0 or c.column < 0) + return false; + return (c.line < line_count() and c.column < m_lines[c.line].length()) or (c.line == line_count() - 1 and c.column == m_lines.back().length()) or (c.line == line_count() and c.column == 0);