mirror of https://gerrit.osmocom.org/osmo-sysmon
fix file descriptor leak in osysmon_file_read
Don't forget to close the file which was opened at the beginning of this function's scope. Found by Coverity. Change-Id: Ie1b5734748438c6d785cd96dfa9af6303cd102da Related: CID#189756
This commit is contained in:
parent
ac0061a30f
commit
908d3cc921
|
@ -77,7 +77,7 @@ static void osysmon_file_destroy(struct osysmon_file *of)
|
|||
static void osysmon_file_read(struct osysmon_file *of, struct value_node *parent)
|
||||
{
|
||||
char buf[512];
|
||||
char *nl;
|
||||
char *s, *nl;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(of->cfg.path, "r");
|
||||
|
@ -85,7 +85,9 @@ static void osysmon_file_read(struct osysmon_file *of, struct value_node *parent
|
|||
value_node_add(parent, parent, of->cfg.name, "<NOTFOUND>");
|
||||
return;
|
||||
}
|
||||
if (fgets(buf, sizeof(buf), f) == NULL) {
|
||||
s = fgets(buf, sizeof(buf), f);
|
||||
fclose(f);
|
||||
if (s == NULL) {
|
||||
value_node_add(parent, parent, of->cfg.name, "<EMPTY>");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue