Skip to content

Commit 27c40ee

Browse files
committed
fix parse_into handling of tuple of the wrong size
1 parent b036074 commit 27c40ee

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

include/boost/json/detail/parse_into.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ class converting_handler<tuple_conversion_tag, T, P>
829829
if( inner_active_ < N )
830830
{
831831
BOOST_JSON_FAIL( ec, error::size_mismatch );
832-
return true;
832+
return false;
833833
}
834834

835835
inner_active_ = -1;

test/parse_into.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,17 @@ class parse_into_test
157157
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
158158
#endif
159159
system::error_code ec;
160-
T t{};
160+
T t1{};
161161
std::string json = serialize(sample);
162-
parser_for<T> p( parse_options{}, &t );
162+
163+
parse_into<T>(t1, json, ec);
164+
BOOST_TEST( ec.failed() );
165+
BOOST_TEST( ec.has_location() );
166+
BOOST_TEST( ec == e );
167+
168+
T t2{};
169+
ec = {};
170+
parser_for<T> p( parse_options{}, &t2 );
163171
for( auto& c: json )
164172
{
165173
std::size_t const n = p.write_some( true, &c, 1, ec );
@@ -355,6 +363,8 @@ class parse_into_test
355363
error::size_mismatch, {1, 2} );
356364
testParseIntoErrors< std::tuple<std::vector<int>> >(
357365
error::size_mismatch, {{1,2}, {3,4}} );
366+
testParseIntoErrors<std::map<std::string, std::tuple<int, int>>>(
367+
error::size_mismatch, { {"tup", array()} });
358368
}
359369

360370
void testStruct()

0 commit comments

Comments
 (0)