Commit f13c34a1 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Avoid crash when resizing receive buffer.

parent 70bc5fe5
...@@ -815,24 +815,26 @@ schedule_neighbours_check(int msecs, int override) ...@@ -815,24 +815,26 @@ schedule_neighbours_check(int msecs, int override)
void void
resize_receive_buffer(int size) resize_receive_buffer(int size)
{ {
char *new;
if(size <= receive_buffer_size) if(size <= receive_buffer_size)
return; return;
if(receive_buffer == NULL) { if(receive_buffer == NULL) {
receive_buffer = malloc(size); receive_buffer = malloc(size);
if(receive_buffer == NULL) if(receive_buffer == NULL) {
perror("malloc(receive_buffer)");
return; return;
}
receive_buffer_size = size;
} else {
unsigned char *new;
new = realloc(receive_buffer, size);
if(new == NULL) {
perror("realloc(receive_buffer)");
return;
}
new = receive_buffer;
receive_buffer_size = size; receive_buffer_size = size;
} }
new = realloc(receive_buffer, size);
if(new == NULL) {
perror("malloc(receive_buffer)");
return;
}
receive_buffer_size = size;
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment