Fix exception in parse_ini_file()

This commit is contained in:
Bob Polis 2024-10-15 12:40:09 +02:00
parent c718b76e1e
commit 06060dab7c

View File

@ -4,6 +4,7 @@
#include <fstream>
#include <algorithm>
#include <locale>
#include <stdexcept>
#include <sys/stat.h>
#include <uninorm.h>
#include <libscerror.hpp>
@ -82,7 +83,7 @@ map<string, string> sc::parse_ini_file(const string& path, bool ignore_sections)
string prefix;
string line;
ifstream file {path};
file.exceptions(ios::badbit); // it seems that getline() will set failbit when confronted with eof immediately
if (!file) throw runtime_error {string {"could not open "} + path};
while (getline(file, line)) {
if (line[0] == '#') continue; // ignore comments
if (line[0] == '[') {