mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
conf-parser: don't close FILE* object if we didn't open it
This commit is contained in:
parent
58783cdaec
commit
63ad1ab4f3
@ -135,6 +135,7 @@ int config_parse(const char *filename, FILE *f, const char* const * sections, co
|
||||
unsigned line = 0;
|
||||
char *section = NULL;
|
||||
int r;
|
||||
bool ours = false;
|
||||
|
||||
assert(filename);
|
||||
assert(t);
|
||||
@ -145,6 +146,8 @@ int config_parse(const char *filename, FILE *f, const char* const * sections, co
|
||||
log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
ours = true;
|
||||
}
|
||||
|
||||
while (!feof(f)) {
|
||||
@ -168,7 +171,7 @@ int config_parse(const char *filename, FILE *f, const char* const * sections, co
|
||||
finish:
|
||||
free(section);
|
||||
|
||||
if (f)
|
||||
if (f && ours)
|
||||
fclose(f);
|
||||
|
||||
return r;
|
||||
|
Loading…
Reference in New Issue
Block a user