[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] When calling getline first time, initialize length to zero.



On Thursday 14 May 2015 13:24:20 Richard W.M. Jones wrote:
> The man page for getline says:
> 
>    ssize_t getline(char **lineptr, size_t *n, FILE *stream);
>  [...]
>    If  *lineptr  is set to NULL and *n is set 0 before the call, then get‐
>    line() will allocate a buffer for storing the line.  This buffer should
>    be freed by the user program even if getline() failed.
> 
> which seems to indicate that we must initialize both line and len to 0
> before the first call to getline.
> 
> In several places we were not initializing len.  The program still
> worked fine, but it seems better to initialize the length anyway.
> ---

LGTM.

-- 
Pino Toscano


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]