[AST] Plug a memory leak when promoting a single ParentMap entry to a vector.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 23 Oct 2015 13:24:18 +0000 (13:24 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 23 Oct 2015 13:24:18 +0000 (13:24 +0000)
Found by asan!

llvm-svn: 251110

clang/lib/AST/ASTContext.cpp

index 90f9dbb..dabc6f6 100644 (file)
@@ -8774,11 +8774,11 @@ createDynTypedNode(const NestedNameSpecifierLoc &Node) {
           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 =