From cd613da050ba4e59064435e4d34d3802561a862c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 25 May 2020 22:43:40 +1000 Subject: [PATCH] Tolerate bliting window that overflow the target Although we try to avoid those, ensuring it never happens is tricky, and tolerating them avoids the crash. Fixes #3498 --- src/terminal_ui.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index 3b87ea0f..2ff84312 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -145,7 +145,7 @@ struct TerminalUI::Window::Line void TerminalUI::Window::blit(Window& target) { - kak_assert(pos.line + lines.size() <= target.lines.size()); + kak_assert(pos.line < target.lines.size()); auto target_line = target.lines.begin() + (size_t)pos.line; for (auto& line : lines) { @@ -153,7 +153,8 @@ void TerminalUI::Window::blit(Window& target) target_line->resize(target.size.column); target_line->atoms.insert(target_line->erase_range(pos.column, size.column), line.atoms.begin(), line.atoms.end()); - ++target_line; + if (++target_line == target.lines.end()) + break; } }