summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-10-28 21:55:08 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-10-28 21:55:08 +0000
commitd29419bcd69432aded1df73cb74853db86daf20d (patch)
treeb1dc9bfacf12ef8c7a2669567eb5c95d159f742a /src/buffer.cc
parent62f56378c949a57ddd08b4d4eacf898758fcb03e (diff)
Fix invalid memory access when applying modifications on an empty buffer
That can happen when undoing/redoing accross a buffer reload boundary.
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index 81804c79..0b0dca1e 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -351,7 +351,9 @@ void Buffer::apply_modification(const Modification& modification)
kak_assert(is_valid(coord));
// in modifications, end coords should be {line_count(), 0}
- kak_assert(coord != ByteCoord(line_count()-1, m_lines.back().length()));
+ kak_assert((m_lines.empty() and coord == ByteCoord{0,0} ) or
+ coord != ByteCoord(line_count()-1, m_lines.back().length()));
+
switch (modification.type)
{
case Modification::Insert: