File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1313#include < rapidjson/reader.h>
1414
1515#include < stack>
16+ #include < limits>
17+ #include < stdexcept>
1618
1719namespace facebook {
1820namespace graphql {
@@ -141,6 +143,8 @@ struct ResponseHandler
141143
142144 bool Int (int i)
143145 {
146+ // https://facebook.github.io/graphql/June2018/#sec-Int
147+ static_assert (sizeof (i) == 4 , " GraphQL only supports 32-bit signed integers" );
144148 auto value = Value (Type::Int);
145149
146150 value.set <IntType>(std::move (i));
@@ -150,17 +154,24 @@ struct ResponseHandler
150154
151155 bool Uint (unsigned int i)
152156 {
157+ if (i > static_cast <unsigned int >(std::numeric_limits<int >::max ()))
158+ {
159+ // https://facebook.github.io/graphql/June2018/#sec-Int
160+ throw std::overflow_error (" GraphQL only supports 32-bit signed integers" );
161+ }
153162 return Int (static_cast <int >(i));
154163 }
155164
156- bool Int64 (int64_t i )
165+ bool Int64 (int64_t /* i */ )
157166 {
158- return Int (static_cast <int >(i));
167+ // https://facebook.github.io/graphql/June2018/#sec-Int
168+ throw std::overflow_error (" GraphQL only supports 32-bit signed integers" );
159169 }
160170
161- bool Uint64 (uint64_t i )
171+ bool Uint64 (uint64_t /* i */ )
162172 {
163- return Int (static_cast <int >(i));
173+ // https://facebook.github.io/graphql/June2018/#sec-Int
174+ throw std::overflow_error (" GraphQL only supports 32-bit signed integers" );
164175 }
165176
166177 bool Double (double d)
You can’t perform that action at this time.
0 commit comments