🚑 fix for #493

Added a test to check if the input stream is good() before executing
getline on it. Also added two test cases that set the failbit and
badbit before calling file_line_buffer.
This commit is contained in:
Niels Lohmann 2017-03-11 19:26:12 +01:00
parent ff0b18d10c
commit 4e49829851
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
3 changed files with 46 additions and 0 deletions

View file

@ -10988,6 +10988,13 @@ basic_json_parser_74:
m_line_buffer.erase(0, num_processed_chars);
// read next line from input stream
m_line_buffer_tmp.clear();
// check if stream is still good
if (not m_stream->good())
{
JSON_THROW(std::invalid_argument("stream error"));
}
std::getline(*m_stream, m_line_buffer_tmp, '\n');
// add line with newline symbol to the line buffer

View file

@ -10022,6 +10022,13 @@ class basic_json
m_line_buffer.erase(0, num_processed_chars);
// read next line from input stream
m_line_buffer_tmp.clear();
// check if stream is still good
if (not m_stream->good())
{
JSON_THROW(std::invalid_argument("stream error"));
}
std::getline(*m_stream, m_line_buffer_tmp, '\n');
// add line with newline symbol to the line buffer