[clang][ASTReader] Fix memory leak while reading FriendTemplateDecls

Allocate on ASTContext, rather than just on heap, so that template
parameter lists are freed up.

Differential Revision: https://reviews.llvm.org/D120081
This commit is contained in:
Kadir Cetinkaya 2022-02-17 22:01:29 +01:00
parent 535e7b09c1
commit 977b1f574f
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
1 changed files with 1 additions and 1 deletions

View File

@ -2103,7 +2103,7 @@ void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
VisitDecl(D);
unsigned NumParams = Record.readInt();
D->NumParams = NumParams;
D->Params = new TemplateParameterList*[NumParams];
D->Params = new (Reader.getContext()) TemplateParameterList *[NumParams];
for (unsigned i = 0; i != NumParams; ++i)
D->Params[i] = Record.readTemplateParameterList();
if (Record.readInt()) // HasFriendDecl