From 924c840e0dd6a32a547a0a9b18bd5b7e99d171a8 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 21 Feb 2023 15:38:00 +0100 Subject: [PATCH] fixed why2_read_socket allocation sizes --- src/chat/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chat/misc.c b/src/chat/misc.c index f6c07c8..6d257b0 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -168,7 +168,7 @@ char *why2_read_socket(int socket) } unsigned short content_size = 0; - char *content_buffer = why2_calloc(2, sizeof(char)); + char *content_buffer = why2_calloc(3, sizeof(char)); //GET LENGTH if (recv(socket, content_buffer, 2, 0) != 2) return NULL; @@ -178,7 +178,7 @@ char *why2_read_socket(int socket) why2_deallocate(content_buffer); //ALLOCATE - content_buffer = why2_calloc(content_size + 1, sizeof(char)); + content_buffer = why2_calloc(content_size + 3, sizeof(char)); //READ FINAL MESSAGE if (recv(socket, content_buffer, content_size, 0) != content_size) fprintf(stderr, "Socket probably read wrongly!\n");