Skip to content

Commit a71fc6f

Browse files
lib/gshadow.c: fgetsgent(): Don't use static variables
Reported-by: Chris Hofstaedtler <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 664817b commit a71fc6f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/gshadow.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ void endsgent (void)
140140
/*@observer@*//*@null@*/struct sgrp *
141141
fgetsgent(/*@null@*/FILE *fp)
142142
{
143-
static size_t buflen = 0;
144-
static char *buf = NULL;
143+
char *buf = NULL;
144+
size_t buflen = 0;
145+
struct sgrp *sg;
145146

146147
if (NULL == fp) {
147148
return NULL;
@@ -152,7 +153,11 @@ fgetsgent(/*@null@*/FILE *fp)
152153
if (stpsep(buf, "\n") == NULL)
153154
return NULL;
154155

155-
return (sgetsgent (buf));
156+
sg = sgetsgent(buf);
157+
158+
free(buf);
159+
160+
return sg;
156161
}
157162

158163

0 commit comments

Comments
 (0)