File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 44#ifndef TAOCPP_JSON_INCLUDE_VALUE_HH
55#define TAOCPP_JSON_INCLUDE_VALUE_HH
66
7+ #include < cmath>
78#include < cassert>
89#include < utility>
10+ #include < stdexcept>
911
1012#include " external/sequences/make_integer_sequence.hpp"
1113
@@ -90,9 +92,10 @@ namespace tao
9092 }
9193
9294 explicit
93- value ( const double d ) noexcept
95+ value ( const double d )
9496 : m_type( json::type::DOUBLE )
9597 {
98+ check_finite ( d );
9699 m_union.d = d;
97100 }
98101
@@ -287,8 +290,9 @@ namespace tao
287290 unsafe_assign ( i );
288291 }
289292
290- void operator = ( const double d ) noexcept
293+ void operator = ( const double d )
291294 {
295+ check_finite ( d );
292296 destroy ();
293297 unsafe_assign ( d );
294298 }
@@ -920,7 +924,14 @@ namespace tao
920924 assert ( false );
921925 }
922926
923- protected:
927+ static void check_finite ( const double d )
928+ {
929+ if ( ! std::isfinite ( d ) ) {
930+ throw std::runtime_error ( " non-finite double value illegal for json" );
931+ }
932+ }
933+
934+ private:
924935 internal::value_union< value > m_union;
925936 json::type m_type;
926937 };
You can’t perform that action at this time.
0 commit comments