From 3a4f5ed7b6f8a8a14ead918ee459d2964792927f Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 18 Feb 2023 17:05:30 +0100 Subject: [PATCH] added empty content check to read_socket --- src/chat/server/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/chat/server/main.c b/src/chat/server/main.c index 0c1e1c6..b0c2f92 100644 --- a/src/chat/server/main.c +++ b/src/chat/server/main.c @@ -79,6 +79,12 @@ char *read_socket(int socket) //COUNT content_size ioctl(socket, FIONREAD, &content_size); + if (content_size == 0) + { + fprintf(stderr, "Reading socket failed."); + return NULL; + } + //ALLOCATE content = why2_calloc(content_size + 1, sizeof(char));