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 23, 2024
1 parent 9991189 commit 5100579
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/gshadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ 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) {
return NULL;
Expand All @@ -152,7 +153,11 @@ fgetsgent(/*@null@*/FILE *fp)
if (stpsep(buf, "\n") == NULL)
return NULL;

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

free(buf);

return sg;
}


Expand Down

0 comments on commit 5100579

Please sign in to comment.