We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f196a7 commit 166f0deCopy full SHA for 166f0de
include/tao/json/stream.hpp
@@ -6,6 +6,7 @@
6
7
#include <iomanip>
8
#include <iosfwd>
9
+#include <stdexcept>
10
11
#include "to_stream.hpp"
12
#include "value.hpp"
@@ -19,9 +20,12 @@ namespace tao
19
20
template< template< typename... > class Traits >
21
std::ostream& operator<<( std::ostream& o, const basic_value< Traits >& v )
22
{
- const std::uint64_t w = o.width( 0 );
23
+ const auto w = o.width( 0 );
24
if( w > 0 ) {
- json::to_stream( o, v, w );
25
+ if( static_cast< std::uint64_t >( w ) > static_cast< std::uint64_t >( std::numeric_limits< std::size_t >::max() ) ) {
26
+ throw std::runtime_error( "indentation too large" );
27
+ }
28
+ json::to_stream( o, v, static_cast< std::size_t >( w ) );
29
}
30
else {
31
json::to_stream( o, v );
0 commit comments