Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying an empty string for an argument description crashes schemagen #106

Closed
wravery opened this issue May 25, 2020 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@wravery
Copy link
Contributor

wravery commented May 25, 2020

If you put empty double quotes (or block quotes) in front of a field argument, schemagen crashes when trying to parse the schema:

std::__uniq_ptr_impl<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> >::_M_ptr(const std::__uniq_ptr_impl<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> > * this) (/usr/include/c++/9/bits/unique_ptr.h:154)
std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> >::get(const std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> > * this) (/usr/include/c++/9/bits/unique_ptr.h:361)
std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> >::operator->(const std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> > * this) (/usr/include/c++/9/bits/unique_ptr.h:355)
graphql::schema::Generator::getInputFields(const std::vector<std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> >, std::allocator<std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> > > > & fields) (cppgraphqlgen/src/SchemaGenerator.cpp:1305)
graphql::schema::Generator::getOutputFields(const std::vector<std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> >, std::allocator<std::unique_ptr<graphql::peg::ast_node, std::default_delete<graphql::peg::ast_node> > > > & fields) (cppgraphqlgen/src/SchemaGenerator.cpp:1201)
graphql::schema::Generator::visitObjectTypeExtension(graphql::peg::ast_node const&)::$_7::operator()(graphql::peg::ast_node const&) const(const class {...} * this, const graphql::peg::ast_node & child) (cppgraphqlgen/src/SchemaGenerator.cpp:806)
std::_Function_handler<void (graphql::peg::ast_node const&), graphql::schema::Generator::visitObjectTypeExtension(graphql::peg::ast_node const&)::$_7>::_M_invoke(std::_Any_data const&, graphql::peg::ast_node const&)(const std::_Any_data & __functor, const graphql::peg::ast_node & __args) (/usr/include/c++/9/bits/std_function.h:300)
std::function<void (graphql::peg::ast_node const&)>::operator()(graphql::peg::ast_node const&) const(const std::function<void (const graphql::peg::ast_node &)> * this, const graphql::peg::ast_node & __args) (/usr/include/c++/9/bits/std_function.h:688)
graphql::peg::on_first_child<graphql::peg::fields_definition>(graphql::peg::ast_node const&, std::function<void (graphql::peg::ast_node const&)>&&)(const graphql::peg::ast_node & n, std::function<void (const graphql::peg::ast_node &)> && func) (cppgraphqlgen/include/graphqlservice/GraphQLGrammar.h:44)
graphql::schema::Generator::visitObjectTypeExtension(graphql::schema::Generator * this, const graphql::peg::ast_node & objectTypeExtension) (cppgraphqlgen/src/SchemaGenerator.cpp:803)
graphql::schema::Generator::visitObjectTypeDefinition(graphql::schema::Generator * this, const graphql::peg::ast_node & objectTypeDefinition) (cppgraphqlgen/src/SchemaGenerator.cpp:778)
graphql::schema::Generator::visitDefinition(graphql::schema::Generator * this, const graphql::peg::ast_node & definition) (cppgraphqlgen/src/SchemaGenerator.cpp:715)
graphql::schema::Generator::Generator(graphql::schema::Generator * this, graphql::schema::GeneratorOptions && options) (cppgraphqlgen/src/SchemaGenerator.cpp:291)
main(int argc, char ** argv) (cppgraphqlgen/src/SchemaGenerator.cpp:3585)

The problem is that the children vector of the description node is empty, so de-referencing front() causes a segmentation fault:

else if (child->is_type<peg::description>())
{
	field.description = child->children.front()->unescaped;
}
@wravery wravery added the bug Something isn't working label May 25, 2020
@wravery wravery self-assigned this May 25, 2020
@wravery
Copy link
Contributor Author

wravery commented May 25, 2020

This is actually a problem everywhere that you can add a description.

wravery added a commit that referenced this issue May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant