Skip to content

Commit

Permalink
lib/gshadow.c: fgetsgent(): Don't use static variables
Browse files Browse the repository at this point in the history
Reported-by: Chris Hofstaedtler <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Jul 22, 2024
1 parent decf456 commit 3e3b374
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/gshadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,23 @@ void endsgent (void)
/*@observer@*//*@null@*/struct sgrp *
fgetsgent(/*@null@*/FILE *fp)
{
static size_t buflen = 0;
static char *buf = NULL;
char *buf = NULL;
size_t buflen = 0;
struct sgrp *sg;

if (NULL == fp) {
if (NULL == fp)
return NULL;
}

if (getline(&buf, &buflen, fp) == -1)
return NULL;
if (stpsep(buf, "\n") == NULL)
return NULL;

return (sgetsgent (buf));
sg = sgetsgent(buf);

free(buf);

return sg;
}


Expand Down

0 comments on commit 3e3b374

Please sign in to comment.