
<       memmove (buf, buf + start, initial_read - start);
---
>       memmove (buf, buf + start, MIN(initial_read - start, bufsize));
