1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

conf-parser: don't close FILE* object if we didn't open it

This commit is contained in:
Lennart Poettering 2010-04-06 02:36:41 +02:00
parent 58783cdaec
commit 63ad1ab4f3

View File

@ -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;