On Tue, Nov 12, 2013 at 04:33:41PM +0100, Dodji Seketeli wrote:
> +
> +      memmove (*line, l, len);
> +      (*line)[len - 1] = '\0';
> +      *line_len = --len;

Shouldn't this be testing that len > 0 && (*line)[len - 1] == '\n'
first before you decide to overwrite it and decrement len?
Though in that case there would be no '\0' termination of the string
for files not ending in a new-line.  So, either get_next_line should
append '\n' to the buffer, or you should have there space for that, or
you can't rely on zero termination of the string and need to use just
the length.

        Jakub

Reply via email to