r191665 - Fix use-after-free.

Manuel Klimek klimek at google.com
Mon Sep 30 06:29:01 PDT 2013


Author: klimek
Date: Mon Sep 30 08:29:01 2013
New Revision: 191665

URL: http://llvm.org/viewvc/llvm-project?rev=191665&view=rev
Log:
Fix use-after-free.

TemplateDeclInstantiator takes the MultiLevelArgumentList by const-ref
and stores a const-ref member. Thus, we must not pass a temporary
into the constructor.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=191665&r1=191664&r2=191665&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Sep 30 08:29:01 2013
@@ -3312,9 +3312,9 @@ VarTemplateSpecializationDecl *Sema::Bui
   // 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 ...
 





More information about the cfe-commits mailing list