From dfc49e7afe905fadae756aa24734629a1afdb0fd Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 24 Nov 2016 21:45:10 +0100 Subject: [PATCH] :bug: fixed a bug if parser was called with a stream at EOF (#367) --- src/json.hpp | 5 ++++- src/json.hpp.re2c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index e71ffc4a..915a60f4 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8743,7 +8743,10 @@ basic_json_parser_66: // append n characters to make sure that there is sufficient // space between m_cursor and m_limit m_line_buffer.append(1, '\x00'); - m_line_buffer.append(n - 1, '\x01'); + if (n > 0) + { + m_line_buffer.append(n - 1, '\x01'); + } } else { diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 9eccc144..9b21c828 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -7892,7 +7892,10 @@ class basic_json // append n characters to make sure that there is sufficient // space between m_cursor and m_limit m_line_buffer.append(1, '\x00'); - m_line_buffer.append(n - 1, '\x01'); + if (n > 0) + { + m_line_buffer.append(n - 1, '\x01'); + } } else {