[llvm] r237389 - Fix memory leak introduced in r237314.

Alex Lorenz arphaman at gmail.com
Thu May 14 13:46:12 PDT 2015


Author: arphaman
Date: Thu May 14 15:46:12 2015
New Revision: 237389

URL: http://llvm.org/viewvc/llvm-project?rev=237389&view=rev
Log:
Fix memory leak introduced in r237314.

The commit r237314 that implements YAML block parsing
introduced a leak that was caught by the ASAN linux buildbot.
YAML Parser stores its tokens in an ilist, and allocates
tokens using a BumpPtrAllocator, but doesn't call the
destructor for the allocated tokens. R237314 added an 
std::string field to a Token which leaked as the Token's
destructor wasn't called. This commit fixes this leak
by calling the Token's destructor when a Token is being
removed from an ilist of tokens.

Modified:
    llvm/trunk/lib/Support/YAMLParser.cpp

Modified: llvm/trunk/lib/Support/YAMLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?rev=237389&r1=237388&r2=237389&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLParser.cpp (original)
+++ llvm/trunk/lib/Support/YAMLParser.cpp Thu May 14 15:46:12 2015
@@ -168,7 +168,7 @@ struct ilist_node_traits<Token> {
   Token *createNode(const Token &V) {
     return new (Alloc.Allocate<Token>()) Token(V);
   }
-  static void deleteNode(Token *V) {}
+  static void deleteNode(Token *V) { V->~Token(); }
 
   void addNodeToList(Token *) {}
   void removeNodeFromList(Token *) {}





More information about the llvm-commits mailing list