From dd05d6c6f57c0b8f2f956b169bcdbb93e70147dd Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 7 Aug 2012 23:18:37 +0200 Subject: [PATCH] BufferIterator: fix operator+ --- src/buffer_iterator.inl.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buffer_iterator.inl.hh b/src/buffer_iterator.inl.hh index 11747d35..9970d4dd 100644 --- a/src/buffer_iterator.inl.hh +++ b/src/buffer_iterator.inl.hh @@ -138,7 +138,7 @@ inline BufferIterator BufferIterator::operator+(BufferSize size) const if (m_buffer->m_lines[i].start > o) return BufferIterator(*m_buffer, { i-1, o - m_buffer->m_lines[i-1].start }); } - int last_line = m_buffer->line_count() - 1; + int last_line = std::max(0, m_buffer->line_count() - 1); return BufferIterator(*m_buffer, { last_line, o - m_buffer->m_lines[last_line].start }); } return operator-(-size);