summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-11-11 17:22:35 +1100
committerMaxime Coste <mawww@kakoune.org>2021-07-12 10:25:59 +1000
commitcbd0dc571bba77d80a5fea1709cc3fbd8bd039f9 (patch)
treea253a5254decc4c156d91c193e2b985a03c337e2 /src
parent76e5d11c8b9d9551bda78bdff8dc58465fe7f5d1 (diff)
Fix crash when displaying a menu on a too small terminal
The code could position the menu at a negative line leading to invalid array accesses.
Diffstat (limited to 'src')
-rw-r--r--src/terminal_ui.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index 14cf330e..34d8eee3 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -26,6 +26,8 @@ using std::max;
void TerminalUI::Window::create(const DisplayCoord& p, const DisplayCoord& s)
{
+ kak_assert(p.line >= 0 and p.column >= 0);
+ kak_assert(s.line >= 0 and s.column >= 0);
pos = p;
size = s;
lines.resize((int)size.line);
@@ -1005,7 +1007,7 @@ void TerminalUI::menu_show(ConstArrayView<DisplayLine> items,
}
else if (not is_inline)
line = m_status_on_top ? 1_line : m_dimensions.line - height;
- else if (line + height > m_dimensions.line)
+ else if (line + height > m_dimensions.line and anchor.line >= height)
line = anchor.line - height;
const auto width = is_search ? m_dimensions.column - m_dimensions.column / 2