diff options
author | Raphael Isemann <teemperor@gmail.com> | 2018-01-23 13:50:46 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2018-01-23 13:50:46 +0000 |
commit | b90f81ed821a14ce9464c02d4ffa7e0a79a9b2b0 (patch) | |
tree | f732e1e674b320618bbc9bc67e4bf55584a933db /lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp | |
parent | a67b3663de05b21af4bcbf2ae46c7230e9892c90 (diff) | |
download | bcm5719-llvm-b90f81ed821a14ce9464c02d4ffa7e0a79a9b2b0.tar.gz bcm5719-llvm-b90f81ed821a14ce9464c02d4ffa7e0a79a9b2b0.zip |
Fix memory leaks in GoParser
Summary: The GoParser is leaking memory in the tests due to not freeing allocated nodes when encountering some parsing errors. With this patch all GoParser tests are passing with enabled memory sanitizers/ubsan.
Reviewers: labath, davide
Reviewed By: labath
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D42409
llvm-svn: 323197
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp')
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp b/lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp index e20d03a0b17..9c845d02bca 100644 --- a/lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Go/GoParser.cpp @@ -439,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; } @@ -548,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) @@ -557,6 +560,7 @@ GoASTExpr *GoParser::Conversion() { return r.error(); GoASTCallExpr *call = new GoASTCallExpr(false); call->SetFun(t); + owner.release(); call->AddArgs(v); return call; } |