diff options
Diffstat (limited to 'src/interface-curses/curses-info-popup.c')
| -rw-r--r-- | src/interface-curses/curses-info-popup.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/interface-curses/curses-info-popup.c b/src/interface-curses/curses-info-popup.c index 83d4665..0e5716d 100644 --- a/src/interface-curses/curses-info-popup.c +++ b/src/interface-curses/curses-info-popup.c @@ -19,6 +19,7 @@ #include "config.h" #endif +#include <stdlib.h> #include <string.h> #include <glib.h> @@ -72,7 +73,7 @@ teco_curses_info_popup_add(teco_curses_info_popup_t *ctx, teco_popup_entry_type_ ctx->length++; } -static void +static gboolean teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr, gshort pair) { int pad_lines; /**! pad height */ @@ -100,6 +101,9 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr, gsho * and right borders. */ ctx->pad = newpad(pad_lines, COLS - 2); + if (G_UNLIKELY(!ctx->pad)) + /* can well fail for huge pad_lines */ + return FALSE; /* * NOTE: attr could contain WA_REVERSE on monochrome terminals, @@ -158,6 +162,8 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr, gsho cur_col++; } + + return TRUE; } void @@ -167,11 +173,9 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr, gshort p /* nothing to display */ return; - if (ctx->window) - delwin(ctx->window); - - if (!ctx->pad) - teco_curses_info_popup_init_pad(ctx, attr, pair); + if (!ctx->pad && G_UNLIKELY(!teco_curses_info_popup_init_pad(ctx, attr, pair))) + /* OOM */ + return; gint pad_lines = getmaxy(ctx->pad); /* @@ -180,8 +184,12 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr, gshort p */ gint popup_lines = MIN(pad_lines + 1, LINES - teco_cmdline.height); + if (ctx->window) + delwin(ctx->window); /* window covers message, scintilla and info windows */ ctx->window = newwin(popup_lines, 0, LINES - teco_cmdline.height - popup_lines, 0); + if (G_UNLIKELY(!ctx->window)) + abort(); wattr_set(ctx->window, attr, pair, NULL); |
