From ac31d9bc5acb719dbd4abf841e176ee2e43e369e Mon Sep 17 00:00:00 2001 From: Tiiffi Date: Fri, 20 Sep 2019 13:36:49 +0300 Subject: [PATCH] Added check for fgets() return value. --- mcrcon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mcrcon.c b/mcrcon.c index ab33748..6af7a07 100644 --- a/mcrcon.c +++ b/mcrcon.c @@ -746,10 +746,10 @@ int get_line(char *buffer, int bsize) int ch, len; fputs(">", stdout); - (void) fgets(buffer, bsize, stdin); + char *ret = fgets(buffer, bsize, stdin); + if (ret == NULL) exit(EXIT_FAILURE); - if (buffer[0] == 0) - global_connection_alive = 0; + if (buffer[0] == 0) global_connection_alive = 0; // remove unwanted characters from the buffer buffer[strcspn(buffer, "\r\n")] = '\0';