File tree 6 files changed +66
-8
lines changed
6 files changed +66
-8
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,16 @@ service::AwaitableResolver Result<learn::Episode>::convert(service::AwaitableSca
53
53
return ModifiedResult<learn::Episode>::resolve (std::move (result), std::move (params),
54
54
[](learn::Episode value, const ResolverParams&)
55
55
{
56
+ const auto idx = static_cast <size_t >(value);
57
+
58
+ if (idx >= s_namesEpisode.size ())
59
+ {
60
+ throw service::schema_exception { { R"ex( Enum value out of range for Episode)ex" } };
61
+ }
62
+
56
63
response::Value resolvedResult (response::Type::EnumValue);
57
64
58
- resolvedResult.set <std::string>(std::string { s_namesEpisode[static_cast < size_t >(value) ] });
65
+ resolvedResult.set <std::string>(std::string { s_namesEpisode[idx ] });
59
66
60
67
return resolvedResult;
61
68
});
Original file line number Diff line number Diff line change @@ -54,9 +54,16 @@ service::AwaitableResolver Result<today::TaskState>::convert(service::AwaitableS
54
54
return ModifiedResult<today::TaskState>::resolve (std::move (result), std::move (params),
55
55
[](today::TaskState value, const ResolverParams&)
56
56
{
57
+ const auto idx = static_cast <size_t >(value);
58
+
59
+ if (idx >= s_namesTaskState.size ())
60
+ {
61
+ throw service::schema_exception { { R"ex( Enum value out of range for TaskState)ex" } };
62
+ }
63
+
57
64
response::Value resolvedResult (response::Type::EnumValue);
58
65
59
- resolvedResult.set <std::string>(std::string { s_namesTaskState[static_cast < size_t >(value) ] });
66
+ resolvedResult.set <std::string>(std::string { s_namesTaskState[idx ] });
60
67
61
68
return resolvedResult;
62
69
});
Original file line number Diff line number Diff line change @@ -54,9 +54,16 @@ service::AwaitableResolver Result<today::TaskState>::convert(service::AwaitableS
54
54
return ModifiedResult<today::TaskState>::resolve (std::move (result), std::move (params),
55
55
[](today::TaskState value, const ResolverParams&)
56
56
{
57
+ const auto idx = static_cast <size_t >(value);
58
+
59
+ if (idx >= s_namesTaskState.size ())
60
+ {
61
+ throw service::schema_exception { { R"ex( Enum value out of range for TaskState)ex" } };
62
+ }
63
+
57
64
response::Value resolvedResult (response::Type::EnumValue);
58
65
59
- resolvedResult.set <std::string>(std::string { s_namesTaskState[static_cast < size_t >(value) ] });
66
+ resolvedResult.set <std::string>(std::string { s_namesTaskState[idx ] });
60
67
61
68
return resolvedResult;
62
69
});
Original file line number Diff line number Diff line change @@ -54,9 +54,16 @@ service::AwaitableResolver Result<validation::DogCommand>::convert(service::Awai
54
54
return ModifiedResult<validation::DogCommand>::resolve (std::move (result), std::move (params),
55
55
[](validation::DogCommand value, const ResolverParams&)
56
56
{
57
+ const auto idx = static_cast <size_t >(value);
58
+
59
+ if (idx >= s_namesDogCommand.size ())
60
+ {
61
+ throw service::schema_exception { { R"ex( Enum value out of range for DogCommand)ex" } };
62
+ }
63
+
57
64
response::Value resolvedResult (response::Type::EnumValue);
58
65
59
- resolvedResult.set <std::string>(std::string { s_namesDogCommand[static_cast < size_t >(value) ] });
66
+ resolvedResult.set <std::string>(std::string { s_namesDogCommand[idx ] });
60
67
61
68
return resolvedResult;
62
69
});
@@ -110,9 +117,16 @@ service::AwaitableResolver Result<validation::CatCommand>::convert(service::Awai
110
117
return ModifiedResult<validation::CatCommand>::resolve (std::move (result), std::move (params),
111
118
[](validation::CatCommand value, const ResolverParams&)
112
119
{
120
+ const auto idx = static_cast <size_t >(value);
121
+
122
+ if (idx >= s_namesCatCommand.size ())
123
+ {
124
+ throw service::schema_exception { { R"ex( Enum value out of range for CatCommand)ex" } };
125
+ }
126
+
113
127
response::Value resolvedResult (response::Type::EnumValue);
114
128
115
- resolvedResult.set <std::string>(std::string { s_namesCatCommand[static_cast < size_t >(value) ] });
129
+ resolvedResult.set <std::string>(std::string { s_namesCatCommand[idx ] });
116
130
117
131
return resolvedResult;
118
132
});
Original file line number Diff line number Diff line change @@ -1336,10 +1336,19 @@ service::AwaitableResolver Result<)cpp"
1336
1336
[]()cpp" << _loader.getSchemaNamespace ()
1337
1337
<< R"cpp( ::)cpp" << enumType.cppType << R"cpp( value, const ResolverParams&)
1338
1338
{
1339
+ const auto idx = static_cast<size_t>(value);
1340
+
1341
+ if (idx >= s_names)cpp"
1342
+ << enumType.cppType << R"cpp( .size())
1343
+ {
1344
+ throw service::schema_exception { { R"ex(Enum value out of range for )cpp"
1345
+ << enumType.type << R"cpp( )ex" } };
1346
+ }
1347
+
1339
1348
response::Value resolvedResult(response::Type::EnumValue);
1340
1349
1341
1350
resolvedResult.set<std::string>(std::string { s_names)cpp"
1342
- << enumType.cppType << R"cpp( [static_cast<size_t>(value) ] });
1351
+ << enumType.cppType << R"cpp( [idx ] });
1343
1352
1344
1353
return resolvedResult;
1345
1354
});
Original file line number Diff line number Diff line change @@ -48,9 +48,16 @@ service::AwaitableResolver Result<introspection::TypeKind>::convert(service::Awa
48
48
return ModifiedResult<introspection::TypeKind>::resolve (std::move (result), std::move (params),
49
49
[](introspection::TypeKind value, const ResolverParams&)
50
50
{
51
+ const auto idx = static_cast <size_t >(value);
52
+
53
+ if (idx >= s_namesTypeKind.size ())
54
+ {
55
+ throw service::schema_exception { { R"ex( Enum value out of range for __TypeKind)ex" } };
56
+ }
57
+
51
58
response::Value resolvedResult (response::Type::EnumValue);
52
59
53
- resolvedResult.set <std::string>(std::string { s_namesTypeKind[static_cast < size_t >(value) ] });
60
+ resolvedResult.set <std::string>(std::string { s_namesTypeKind[idx ] });
54
61
55
62
return resolvedResult;
56
63
});
@@ -104,9 +111,16 @@ service::AwaitableResolver Result<introspection::DirectiveLocation>::convert(ser
104
111
return ModifiedResult<introspection::DirectiveLocation>::resolve (std::move (result), std::move (params),
105
112
[](introspection::DirectiveLocation value, const ResolverParams&)
106
113
{
114
+ const auto idx = static_cast <size_t >(value);
115
+
116
+ if (idx >= s_namesDirectiveLocation.size ())
117
+ {
118
+ throw service::schema_exception { { R"ex( Enum value out of range for __DirectiveLocation)ex" } };
119
+ }
120
+
107
121
response::Value resolvedResult (response::Type::EnumValue);
108
122
109
- resolvedResult.set <std::string>(std::string { s_namesDirectiveLocation[static_cast < size_t >(value) ] });
123
+ resolvedResult.set <std::string>(std::string { s_namesDirectiveLocation[idx ] });
110
124
111
125
return resolvedResult;
112
126
});
You can’t perform that action at this time.
0 commit comments