When calling getline first time, initialize length to zero.

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.
This commit is contained in:
Richard W.M. Jones
2015-05-14 13:22:00 +01:00
parent 7eb1ed8cb4
commit 5bf7f770b6
4 changed files with 5 additions and 5 deletions

View File

@@ -109,7 +109,7 @@ auth_callback (guestfs_h *g,
size_t i;
char *prompt;
char *reply = NULL;
size_t allocsize;
size_t allocsize = 0;
char *pass;
ssize_t len;
int r;