From 3a4859ecba4518ea335e4f5958f1af49bb33bf59 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 27 Nov 2012 18:54:27 +0100 Subject: [PATCH] ncurses: avoid refering to dead NCursesUI in signal handler --- src/ncurses.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ncurses.cc b/src/ncurses.cc index f827471b..2f23229b 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -78,6 +78,9 @@ static void set_color(Color fg_color, Color bg_color) static NCursesUI* signal_ui = nullptr; void on_term_resize(int) { + if (not signal_ui) + return; + int fd = open("/dev/tty", O_RDWR); winsize ws; if (fd == -1 or ioctl(fd, TIOCGWINSZ, (void*)&ws) != 0) @@ -123,6 +126,8 @@ NCursesUI::NCursesUI() NCursesUI::~NCursesUI() { endwin(); + assert(signal_ui == this); + signal_ui = nullptr; } static void redraw(WINDOW* menu_win)