r251110 - [AST] Plug a memory leak when promoting a single ParentMap entry to a vector.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 06:24:19 PDT 2015


Author: d0k
Date: Fri Oct 23 08:24:18 2015
New Revision: 251110

URL: http://llvm.org/viewvc/llvm-project?rev=251110&view=rev
Log:
[AST] Plug a memory leak when promoting a single ParentMap entry to a vector.

Found by asan!

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=251110&r1=251109&r2=251110&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Oct 23 08:24:18 2015
@@ -8774,11 +8774,11 @@ createDynTypedNode(const NestedNameSpeci
           if (!NodeOrVector.template is<ASTContext::ParentVector *>()) {
             auto *Vector = new ASTContext::ParentVector(
                 1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
-            NodeOrVector = Vector;
             if (auto *Node =
                     NodeOrVector
                         .template dyn_cast<ast_type_traits::DynTypedNode *>())
               delete Node;
+            NodeOrVector = Vector;
           }
 
           auto *Vector =




More information about the cfe-commits mailing list