fixed read_socket memory problems
This commit is contained in:
parent
7b51acba52
commit
e77e578be8
@ -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!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user