From b34fc9bf1155a22e881a1b0c806ed349e17ae57f Mon Sep 17 00:00:00 2001 From: Brian Barto Date: Thu, 28 Apr 2016 15:59:00 -0400 Subject: [PATCH] Fix for issue #6: "Segfaults when input is piped from non-existant program" modified: src/nms.c --- src/nms.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nms.c b/src/nms.c index 391de45..93c3660 100644 --- a/src/nms.c +++ b/src/nms.c @@ -44,7 +44,8 @@ char getMaskChar(void); * void nms_exec(NmsArgs *) * * DESCR: - * Performs "decryption" effect, + * Performs "decryption" effect, Returns the character pressed at the last pause, or + * '\0' (null character) if there are any problems. * * ARGS: * NmsArgs *args - Pointer to argument structure @@ -68,6 +69,13 @@ char nms_exec(NmsArgs *args) { bool first = true; char ret = 0; + // Lets check args.src and make sure we have text. If not, return + // with an error message. + if (args->src == NULL) { + fprintf(stderr, "Error. No data found in args.src\n"); + return 0; + } + // Start and initialize curses mode initscr(); cbreak();