Skip to content

Commit 4f196a7

Browse files
committed
Fix another warning from MSVC
1 parent 09239fe commit 4f196a7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

include/tao/json/events/ubjson/grammar.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace tao
162162
}
163163

164164
template< typename Input >
165-
static std::size_t read_size( Input& in )
165+
static std::uint64_t read_unsigned( Input& in )
166166
{
167167
in.bump_in_this_line(); // Skip marker byte.
168168
if( !in.size( 1 ) ) {
@@ -187,6 +187,16 @@ namespace tao
187187
throw json_pegtl::parse_error( "unexpected ubjson high precision number size marker", in );
188188
}
189189

190+
template< typename Input >
191+
static std::size_t read_size( Input& in )
192+
{
193+
const auto s = read_unsigned( in );
194+
if( s > static_cast< std::uint64_t >( std::numeric_limits< std::size_t >::max() ) ) {
195+
throw json_pegtl::parse_error( "size too large for 32-bit platform", in );
196+
}
197+
return static_cast< std::size_t >( s );
198+
}
199+
190200
template< typename Input, typename Consumer >
191201
static bool match_high_precision( Input& in, Consumer& consumer )
192202
{

0 commit comments

Comments
 (0)