From 64c8e378b251669241a3565adf2c8f2d792e1b8d Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 13 Aug 2026 00:49:42 +0200 Subject: curses: check for return values of newpad() and newwin() These can fail, so abort() just like glib does internally in case of OOM. A special case is the pad allocation for autocompletion popups, which can have excessively many lines. This is handled gracefully now (the popup simply won't be displayed). --- src/interface-curses/interface.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/interface-curses/interface.c') diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 11441d2..db996f5 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -761,7 +761,11 @@ teco_interface_init_interactive(GError **error) leaveok(stdscr, TRUE); teco_interface.info_window = newwin(1, 0, 0, 0); + if (G_UNLIKELY(!teco_interface.info_window)) + abort(); teco_interface.msg_window = newwin(1, 0, LINES - teco_cmdline.height - 1, 0); + if (G_UNLIKELY(!teco_interface.msg_window)) + abort(); WINDOW *cmdline_win = teco_view_get_window(teco_cmdline.view); wresize(cmdline_win, teco_cmdline.height, COLS); @@ -769,6 +773,8 @@ teco_interface_init_interactive(GError **error) teco_cmdline_resized(COLS); teco_interface.input_pad = newpad(1, 1); + if (G_UNLIKELY(!teco_interface.input_pad)) + abort(); /* * Controlling function key processing is important * on Unix Curses, as ESCAPE is handled as the beginning -- cgit v1.2.3