]> granicus.if.org Git - clang/commitdiff
Fix use-after-free.
authorManuel Klimek <klimek@google.com>
Mon, 30 Sep 2013 13:29:01 +0000 (13:29 +0000)
committerManuel Klimek <klimek@google.com>
Mon, 30 Sep 2013 13:29:01 +0000 (13:29 +0000)
TemplateDeclInstantiator takes the MultiLevelArgumentList by const-ref
and stores a const-ref member. Thus, we must not pass a temporary
into the constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191665 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp

index 8d384b915b479b6c1658e4e7f97a56aee084d0c8..35f3616db6a017c2d749541c7e83ba03113a2b77 100644 (file)
@@ -3312,9 +3312,9 @@ VarTemplateSpecializationDecl *Sema::BuildVarTemplateInstantiation(
   // we want to instantiate a definition.
   FromVar = FromVar->getFirstDeclaration();
 
-  TemplateDeclInstantiator Instantiator(
-      *this, FromVar->getDeclContext(),
-      MultiLevelTemplateArgumentList(TemplateArgList));
+  MultiLevelTemplateArgumentList MultiLevelList(TemplateArgList);
+  TemplateDeclInstantiator Instantiator(*this, FromVar->getDeclContext(),
+                                        MultiLevelList);
 
   // TODO: Set LateAttrs and StartingScope ...