There was an infinite loop in case of a file without section header on first line!
This commit is contained in:
parent
041791eb4b
commit
a3d7e396b4
1 changed files with 12 additions and 4 deletions
|
|
@ -98,8 +98,8 @@ void eoState::load(std::istream& is)
|
||||||
string str = "Error while reading stream";
|
string str = "Error while reading stream";
|
||||||
throw runtime_error(str);
|
throw runtime_error(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(is)
|
while(! is.eof())
|
||||||
{ // parse section header
|
{ // parse section header
|
||||||
if (is_section(str, name))
|
if (is_section(str, name))
|
||||||
{
|
{
|
||||||
|
|
@ -125,8 +125,10 @@ void eoState::load(std::istream& is)
|
||||||
|
|
||||||
while (getline(is, str))
|
while (getline(is, str))
|
||||||
{
|
{
|
||||||
if (is_section(str, name))
|
if (is.eof())
|
||||||
break;
|
throw runtime_error("No section in load file");
|
||||||
|
if (is_section(str, name))
|
||||||
|
break;
|
||||||
|
|
||||||
removeComment(str, getCommentString());
|
removeComment(str, getCommentString());
|
||||||
fullstring += str + "\n";
|
fullstring += str + "\n";
|
||||||
|
|
@ -139,6 +141,12 @@ void eoState::load(std::istream& is)
|
||||||
object->readFrom(the_stream);
|
object->readFrom(the_stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // if (is_section(str, name)) - what if file empty
|
||||||
|
{
|
||||||
|
getline(is, str); // try next line!
|
||||||
|
// if (is.eof())
|
||||||
|
// throw runtime_error("No section in load file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue