Skip to content

Commit f17c26c

Browse files
author
Monika Rathor
committed
Fix mem leak when failure is set
1 parent 28808fd commit f17c26c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

GraphQLParser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ namespace graphql {
1919
// Given properly-configured yylex, run the parser and return the
2020
// result.
2121
static std::unique_ptr<ast::Node> doParse(const char **outError, yyscan_t scanner, bool enableSchema) {
22-
Node *outAST;
22+
Node *outAST = NULL;
2323
yy::GraphQLParserImpl parser(enableSchema, &outAST, outError, scanner);
2424
int failure = parser.parse();
25+
if (failure) {
26+
delete outAST;
27+
}
2528
return !failure ? std::unique_ptr<ast::Node>(outAST) : nullptr;
2629
}
2730

0 commit comments

Comments
 (0)