diff options
Diffstat (limited to 'source/Plugins/ExpressionParser/Go/GoParser.cpp')
| -rw-r--r-- | source/Plugins/ExpressionParser/Go/GoParser.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/Plugins/ExpressionParser/Go/GoParser.cpp b/source/Plugins/ExpressionParser/Go/GoParser.cpp index 538bd05e25f8..9c845d02bca0 100644 --- a/source/Plugins/ExpressionParser/Go/GoParser.cpp +++ b/source/Plugins/ExpressionParser/Go/GoParser.cpp @@ -67,7 +67,9 @@ private: size_t m_pos; }; -GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false) {} +GoParser::GoParser(const char *src) + : m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID), + m_failed(false) {} GoASTStmt *GoParser::Statement() { Rule r("Statement", this); @@ -437,8 +439,10 @@ GoASTExpr *GoParser::CompositeLit() { if (!type) return r.error(); GoASTCompositeLit *lit = LiteralValue(); - if (!lit) + if (!lit) { + delete type; return r.error(); + } lit->SetType(type); return lit; } @@ -546,6 +550,7 @@ GoASTExpr *GoParser::Arguments(GoASTExpr *e) { GoASTExpr *GoParser::Conversion() { Rule r("Conversion", this); if (GoASTExpr *t = Type2()) { + std::unique_ptr<GoASTExpr> owner(t); if (match(GoLexer::OP_LPAREN)) { GoASTExpr *v = Expression(); if (!v) @@ -555,6 +560,7 @@ GoASTExpr *GoParser::Conversion() { return r.error(); GoASTCallExpr *call = new GoASTCallExpr(false); call->SetFun(t); + owner.release(); call->AddArgs(v); return call; } |
