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 13
13
#include < rapidjson/reader.h>
14
14
15
15
#include < stack>
16
+ #include < limits>
17
+ #include < stdexcept>
16
18
17
19
namespace facebook {
18
20
namespace graphql {
@@ -141,6 +143,8 @@ struct ResponseHandler
141
143
142
144
bool Int (int i)
143
145
{
146
+ // https://facebook.github.io/graphql/June2018/#sec-Int
147
+ static_assert (sizeof (i) == 4 , " GraphQL only supports 32-bit signed integers" );
144
148
auto value = Value (Type::Int);
145
149
146
150
value.set <IntType>(std::move (i));
@@ -150,17 +154,24 @@ struct ResponseHandler
150
154
151
155
bool Uint (unsigned int i)
152
156
{
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
+ }
153
162
return Int (static_cast <int >(i));
154
163
}
155
164
156
- bool Int64 (int64_t i )
165
+ bool Int64 (int64_t /* i */ )
157
166
{
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" );
159
169
}
160
170
161
- bool Uint64 (uint64_t i )
171
+ bool Uint64 (uint64_t /* i */ )
162
172
{
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" );
164
175
}
165
176
166
177
bool Double (double d)
You can’t perform that action at this time.
0 commit comments