From f17c26c5520516c17bac9fd802a6b51d1b8b6514 Mon Sep 17 00:00:00 2001 From: Monika Rathor Date: Sat, 12 May 2018 15:27:08 -0700 Subject: [PATCH] Fix mem leak when failure is set --- GraphQLParser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GraphQLParser.cpp b/GraphQLParser.cpp index 5a8f4c0..9f3ea5e 100644 --- a/GraphQLParser.cpp +++ b/GraphQLParser.cpp @@ -19,9 +19,12 @@ namespace graphql { // Given properly-configured yylex, run the parser and return the // result. static std::unique_ptr doParse(const char **outError, yyscan_t scanner, bool enableSchema) { - Node *outAST; + Node *outAST = NULL; yy::GraphQLParserImpl parser(enableSchema, &outAST, outError, scanner); int failure = parser.parse(); + if (failure) { + delete outAST; + } return !failure ? std::unique_ptr(outAST) : nullptr; }