1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-13 20:21:48 +03:00

🐛 parsing erroneous files yields an exception (#366)

This commit is contained in:
Niels Lohmann
2016-11-23 16:57:01 +01:00
parent ed611119d9
commit 4bb41d065b
3 changed files with 18 additions and 0 deletions

View File

@ -7597,6 +7597,12 @@ class basic_json
explicit lexer(std::istream& s)
: m_stream(&s), m_line_buffer()
{
// immediately abort if stream is erroneous
if (s.fail())
{
throw std::invalid_argument("stream error: " + std::string(strerror(errno)));
}
// fill buffer
fill_line_buffer();