From: Manuel Klimek Date: Mon, 30 Sep 2013 13:29:01 +0000 (+0000) Subject: Fix use-after-free. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e563c28c456b48f43f38f5a92a4bc292d5cda91;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191665 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 8d384b915b..35f3616db6 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -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 ...