Skip to content

Commit 9d55a3c

Browse files
authored
Merge pull request #63 from monikasoni/master
Fix mem leak when failure is set
2 parents 28808fd + f17c26c commit 9d55a3c

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)