Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses curses: application should exit if initscr(3) ...



details:   https://anonhg.NetBSD.org/src/rev/c9bce5710450
branches:  trunk
changeset: 970080:c9bce5710450
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Mar 11 21:33:38 2020 +0000

description:
curses: application should exit if initscr(3) fails

POSIX defines this behaviour here:
https://pubs.opengroup.org/onlinepubs/7908799/xcurses/initscr.html

Partial fix for PR lib/23910

diffstat:

 lib/libcurses/initscr.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r e4974dbaaecf -r c9bce5710450 lib/libcurses/initscr.c
--- a/lib/libcurses/initscr.c   Wed Mar 11 21:07:40 2020 +0000
+++ b/lib/libcurses/initscr.c   Wed Mar 11 21:33:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initscr.c,v 1.33 2018/10/02 17:35:44 roy Exp $ */
+/*     $NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,10 +34,11 @@
 #if 0
 static char sccsid[] = "@(#)initscr.c  8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: initscr.c,v 1.33 2018/10/02 17:35:44 roy Exp $");
+__RCSID("$NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $");
 #endif
 #endif /* not lint */
 
+#include <err.h>
 #include <stdlib.h>
 
 #include "curses.h"
@@ -66,7 +67,7 @@
 
        /* LINTED const castaway; newterm does not modify sp! */
        if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL)
-               return NULL;
+               errx(EXIT_FAILURE, "initscr"); /* POSIX says exit on failure */
 
        set_term(_cursesi_screen);
        wrefresh(curscr);



Home | Main Index | Thread Index | Old Index