[PATCH] D120081: [clang][ASTReader] Fix memory leak while reading FriendTemplateDecls
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 17 13:02:47 PST 2022
kadircet created this revision.
kadircet added a reviewer: sammccall.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Allocate on ASTContext, rather than just on heap, so that template
parameter lists are freed up.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120081
Files:
clang/lib/Serialization/ASTReaderDecl.cpp
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2103,7 +2103,7 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120081.409762.patch
Type: text/x-patch
Size: 593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220217/e6a50de0/attachment.bin>
More information about the cfe-commits
mailing list