Skip to content

Commit

Permalink
readvp2 should always initialise pfiledone in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Feb 2, 2015
1 parent 15333a9 commit 91d6bfe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/pair.c
Expand Up @@ -1762,7 +1762,6 @@ int readvp2(TALLOC_CTX *ctx, VALUE_PAIR **out, FILE *fp, bool *pfiledone)
vp_cursor_t cursor;

VALUE_PAIR *vp = NULL;

fr_cursor_init(&cursor, out);

while (fgets(buf, sizeof(buf), fp) != NULL) {
Expand All @@ -1771,7 +1770,10 @@ int readvp2(TALLOC_CTX *ctx, VALUE_PAIR **out, FILE *fp, bool *pfiledone)
* the end of that VP
*/
if (buf[0] == '\n') {
if (vp) return 0;
if (vp) {
*pfiledone = false;
return 0;
}
continue;
}

Expand All @@ -1793,12 +1795,12 @@ int readvp2(TALLOC_CTX *ctx, VALUE_PAIR **out, FILE *fp, bool *pfiledone)
fr_cursor_merge(&cursor, vp);
buf[0] = '\0';
}

*pfiledone = true;

return 0;

error:
*pfiledone = false;
vp = fr_cursor_first(&cursor);
if (vp) pairfree(&vp);

Expand Down

0 comments on commit 91d6bfe

Please sign in to comment.