Skip to content

Commit

Permalink
Fix resource leaks dealing with unrecognised config file version
Browse files Browse the repository at this point in the history
Plug leaks of an open file descriptor and dynamically allocated
'option' when we bail out early reading unknown config version.
  • Loading branch information
natoscott authored and BenBE committed Aug 31, 2021
1 parent 1f2f567 commit b81bb90
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
// the version of the config file on disk is newer than what we can read
fprintf(stderr, "WARNING: %s specifies configuration format version v%d, but this %s binary supports up to v%d.", fileName, this->config_version, PACKAGE, CONFIG_READER_MIN_VERSION);
fprintf(stderr, " The configuration version will be downgraded to v%d when %s exits.\n", CONFIG_READER_MIN_VERSION, PACKAGE);
String_freeArray(option);
fclose(fd);
return false;
}
} else if (String_eq(option[0], "fields")) {
Expand Down

0 comments on commit b81bb90

Please sign in to comment.