Skip to content
Snippets Groups Projects
Commit d5a05dd2 authored by Kostya Serebryany's avatar Kostya Serebryany
Browse files

Fix leak in lib/CodeGen/CGException.cpp, PR18318

Summary: This fixes the leak described in http://llvm.org/bugs/show_bug.cgi?id=18318

Reviewers: chandlerc, dblaikie

Reviewed By: chandlerc

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2474

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198857 91177308-0d34-0410-b5e6-96231b3b80d8
parent f85faeec
No related branches found
No related tags found
No related merge requests found
...@@ -194,6 +194,15 @@ public: ...@@ -194,6 +194,15 @@ public:
return getHandlers()[I]; return getHandlers()[I];
} }
// Clear all handler blocks.
// FIXME: it's better to always call clearHandlerBlocks in DTOR and have a
// 'takeHandler' or some such function which removes ownership from the
// EHCatchScope object if the handlers should live longer than EHCatchScope.
void clearHandlerBlocks() {
for (unsigned I = 0, N = getNumHandlers(); I != N; ++I)
delete getHandler(I).Block;
}
typedef const Handler *iterator; typedef const Handler *iterator;
iterator begin() const { return getHandlers(); } iterator begin() const { return getHandlers(); }
iterator end() const { return getHandlers() + getNumHandlers(); } iterator end() const { return getHandlers() + getNumHandlers(); }
......
...@@ -1244,6 +1244,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) { ...@@ -1244,6 +1244,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
// If the catch was not required, bail out now. // If the catch was not required, bail out now.
if (!CatchScope.hasEHBranches()) { if (!CatchScope.hasEHBranches()) {
CatchScope.clearHandlerBlocks();
EHStack.popCatch(); EHStack.popCatch();
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment