diff --git a/src/config_file.c b/src/config_file.c index 135871950..2374b383c 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -499,7 +499,8 @@ static int cfg_getchar(diskfile_backend *cfg_file, int flags) assert(cfg_file->reader.read_ptr); do c = cfg_getchar_raw(cfg_file); - while (skip_whitespace && isspace(c)); + while (skip_whitespace && isspace(c) && + !cfg_file->reader.eof); if (skip_comments && (c == '#' || c == ';')) { do c = cfg_getchar_raw(cfg_file); @@ -844,7 +845,8 @@ static int config_parse(diskfile_backend *cfg_file) c = cfg_peek(cfg_file, SKIP_WHITESPACE); switch (c) { - case '\0': /* We've arrived at the end of the file */ + case '\n': /* EOF when peeking, set EOF in the reader to exit the loop */ + cfg_file->reader.eof = 1; break; case '[': /* section header, new section begins */