Skip to content

Commit 517cb85

Browse files
author
fcojavmc
committed
BUG: When I make an instrospection query with non-valid type name as
parameter the program crashes. I've see that the method 'Schema::LookupType' tries to find the name of the type in the '_typeMap' map, but it assumes that always exists, and this is not correct. Result: Crash (Core dump). Reproducible: Always. O.S.: GNU/Linux (OpenSuse) GCC version: 9.2.1 schema.graphql ------------------- schema { query: Query } "My description" type Query { myData: String } ------------------- valid_query_file.graphql ---------------------------- { __type(name: "Query") { description } } ---------------------------- crash_query_file.graphql ---------------------------- { __type(name: "Other") { description } } ----------------------------
1 parent 2379843 commit 517cb85

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Introspection.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ void Schema::AddType(response::StringType&& name, std::shared_ptr<object::Type>
3232

3333
const std::shared_ptr<object::Type>& Schema::LookupType(const response::StringType& name) const
3434
{
35+
if (_typeMap.find(name) == _typeMap.cend())
36+
{
37+
throw service::schema_exception { { "type not found" } };
38+
}
39+
3540
return _types[_typeMap.find(name)->second].second;
3641
}
3742

0 commit comments

Comments
 (0)