2
0
mirror of https://github.com/boostorg/json.git synced 2026-01-19 16:22:20 +00:00

fix reading beyond input buffer

This fixes a rare case when the parser first suspends inside a comment,
then is given input exactly up to the newline character. Before the fix
it proceeded to read past the end of the buffer or hit an assert.
This commit is contained in:
Dmitry Arkhipov
2023-08-24 21:24:08 +03:00
parent f48b6dd4b0
commit 2acdb29a32
3 changed files with 23 additions and 1 deletions

View File

@@ -1109,6 +1109,20 @@ public:
// no newline at EOF
TEST_GOOD_EXT("1//", enabled);
{
parse_options po;
po.allow_comments = true;
fail_parser p(po);
error_code ec;
p.write(true, "//", 2, ec); // suspend while inside comment
BOOST_TEST( !ec.failed() );
p.write(true, " \n1", 2, ec); // input ends comment,
// number starts after current input
BOOST_TEST( !ec.failed() );
p.write(false, "1", 1, ec);
BOOST_TEST( !ec.failed() );
}
}
void