[clang] 977b1f5 - [clang][ASTReader] Fix memory leak while reading FriendTemplateDecls
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 18 03:16:46 PST 2022
Author: Kadir Cetinkaya
Date: 2022-02-18T12:16:38+01:00
New Revision: 977b1f574fa18219fde5f709b906c79202ef1916
URL: https://github.com/llvm/llvm-project/commit/977b1f574fa18219fde5f709b906c79202ef1916
DIFF: https://github.com/llvm/llvm-project/commit/977b1f574fa18219fde5f709b906c79202ef1916.diff
LOG: [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
Added:
Modified:
clang/lib/Serialization/ASTReaderDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 25d7e9e6a2e68..29bef2aa20897 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -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
More information about the cfe-commits
mailing list