[PATCH] D42409: Fix memory leaks in GoParser

Raphael Isemann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 05:52:47 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL323197: Fix memory leaks in GoParser (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42409?vs=131007&id=131052#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42409

Files:
  lldb/trunk/source/Plugins/ExpressionParser/Go/GoParser.cpp


Index: lldb/trunk/source/Plugins/ExpressionParser/Go/GoParser.cpp
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -439,8 +439,10 @@
   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::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 @@
         return r.error();
       GoASTCallExpr *call = new GoASTCallExpr(false);
       call->SetFun(t);
+      owner.release();
       call->AddArgs(v);
       return call;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42409.131052.patch
Type: text/x-patch
Size: 931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180123/9f53e1b0/attachment.bin>


More information about the llvm-commits mailing list