Fix initscr() crash on NetBSD - noice - small file browser (mirror / fork from … | |
git clone git://git.codemadness.org/noice | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 3ccbaef87bb70273a6181b298aee01b0cb1f29ab | |
parent 829bcdd7d419b8e07d77edfa9b9878f0f399a99f | |
Author: sin <[email protected]> | |
Date: Thu, 10 Mar 2016 17:00:12 +0000 | |
Fix initscr() crash on NetBSD | |
NetBSD has its own curses implementation and initscr() does not | |
terminate with an error if TERM is not set properly. | |
Instead check the return value and exit if an initialization | |
error occurs. | |
Diffstat: | |
M noice.c | 11 ++++++++++- | |
1 file changed, 10 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/noice.c b/noice.c | |
@@ -257,7 +257,16 @@ entrycmp(const void *va, const void *vb) | |
void | |
initcurses(void) | |
{ | |
- initscr(); | |
+ char *term; | |
+ | |
+ if (initscr() == NULL) { | |
+ term = getenv("TERM"); | |
+ if (term != NULL) | |
+ fprintf(stderr, "error opening terminal: %s\n", term); | |
+ else | |
+ fprintf(stderr, "failed to initialize curses\n"); | |
+ exit(1); | |
+ } | |
cbreak(); | |
noecho(); | |
nonl(); |