Close fd if there was an empty return.
* Not closing will use up all file descriptors over time.
This commit is contained in:
parent
a30f9f5bd1
commit
81cdc8f4a2
|
@ -106,8 +106,10 @@ readfile(char *base, char *file)
|
|||
if (fd == NULL)
|
||||
return NULL;
|
||||
|
||||
if (fgets(line, sizeof(line)-1, fd) == NULL)
|
||||
if (fgets(line, sizeof(line)-1, fd) == NULL) {
|
||||
fclose(fd);
|
||||
return NULL;
|
||||
}
|
||||
fclose(fd);
|
||||
|
||||
return smprintf("%s", line);
|
||||
|
|
Loading…
Reference in New Issue