From abe76d79f0bc8a6d6872171b19d10a06ec6bc07b Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 25 Jan 2024 11:23:54 +0100 Subject: [PATCH] added return value check to client & server getline --- src/chat/main/client.c | 2 +- src/chat/main/server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chat/main/client.c b/src/chat/main/client.c index a4450e0..9bc8347 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -51,7 +51,7 @@ int main(void) //GET IP printf("Welcome.\n\nEnter IP Address:\n>>> "); - getline(&line, &line_length, stdin); + if (getline(&line, &line_length, stdin) == -1) why2_die("Reading input failed."); //TODO: Add enums to why2_die() server_addr.sin_addr.s_addr = inet_addr(line); diff --git a/src/chat/main/server.c b/src/chat/main/server.c index 5674b01..d16824d 100644 --- a/src/chat/main/server.c +++ b/src/chat/main/server.c @@ -61,7 +61,7 @@ int main(void) for (;;) { - getline(&line_buffer, &line_length_buffer, stdin); + if (getline(&line_buffer, &line_length_buffer, stdin) == -1) why2_die("Reading input failed."); if (strcmp(line_buffer, "!exit\n") == 0) //USER REQUESTED PROGRAM EXIT {