mirror of
https://github.com/nlohmann/json.git
synced 2025-07-25 13:41:56 +03:00
fixed a bug for short input files (#344)
For input files with less than 5 bytes, the parser had a bug so that refilling the input buffer led to erasing it.
This commit is contained in:
12
src/json.hpp
12
src/json.hpp
@ -8598,11 +8598,15 @@ basic_json_parser_63:
|
||||
// no stream is used or end of file is reached
|
||||
if (m_stream == nullptr or m_stream->eof())
|
||||
{
|
||||
// copy unprocessed characters to line buffer
|
||||
m_line_buffer.clear();
|
||||
for (m_cursor = m_start; m_cursor != m_limit; ++m_cursor)
|
||||
// skip this part if we are already using the line buffer
|
||||
if (m_start != reinterpret_cast<const lexer_char_t*>(m_line_buffer.data()))
|
||||
{
|
||||
m_line_buffer.append(1, static_cast<const char>(*m_cursor));
|
||||
// copy unprocessed characters to line buffer
|
||||
m_line_buffer.clear();
|
||||
for (m_cursor = m_start; m_cursor != m_limit; ++m_cursor)
|
||||
{
|
||||
m_line_buffer.append(1, static_cast<const char>(*m_cursor));
|
||||
}
|
||||
}
|
||||
|
||||
// append 5 characters (size of longest keyword "false") to
|
||||
|
Reference in New Issue
Block a user