fixed read_socket memory problems

This commit is contained in:
Václav Šmejkal 2023-02-09 19:46:38 +01:00
parent 7b51acba52
commit e77e578be8
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -65,14 +65,14 @@ int main(void)
char *read_socket(int socket)
{
long content_size;
char *content;
long content_size = 0;
char *content = NULL;
//COUNT content_size
ioctl(socket, FIONREAD, &content_size);
//ALLOCATE
content = why2_calloc(content_size, sizeof(char));
content = why2_calloc(content_size + 1, sizeof(char));
//READ
if (read(socket, content, content_size) != content_size) why2_die("Reading socket failed!");