From 415e155e3f014297aae8f19eddf623b9cb83eae9 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Jul 2016 12:28:34 +0200 Subject: fixed segfault on -c option. has_colors() was called before initscr(). also added error message if terminal does not support colors (and then exit). Signed-off-by: root --- listen/utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/listen/utils.c b/listen/utils.c index 667bab7..f5b3b08 100644 --- a/listen/utils.c +++ b/listen/utils.c @@ -81,9 +81,11 @@ void lprintf(int dtype, char *fmt, ...) int initcolor(void) { - if (!has_colors()) - return 0; initscr(); /* Start ncurses */ + if (!has_colors()) { endwin(); + fprintf(stderr, "Your terminal does not support color\n"); + exit(1); + } start_color(); /* Initialize color support */ refresh(); /* Clear screen */ noecho(); /* Don't echo */ -- cgit v1.2.3