Skip to content

Commit

Permalink
[clang][ASTReader] Fix memory leak while reading FriendTemplateDecls
Browse files Browse the repository at this point in the history
Allocate on ASTContext, rather than just on heap, so that template
parameter lists are freed up.

Differential Revision: https://reviews.llvm.org/D120081
  • Loading branch information
kadircet committed Feb 18, 2022
1 parent 535e7b0 commit 977b1f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTReaderDecl.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 977b1f5

Please sign in to comment.