diff options
| author | Kostya Serebryany <kcc@google.com> | 2014-01-09 09:22:32 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2014-01-09 09:22:32 +0000 |
| commit | ba4acedb691a7748353d630902cb13afe9897f45 (patch) | |
| tree | 28e7e27c7114b1e2fdbe11e8582d83dc36da6d7e | |
| parent | 006a05bcaccd73778c993d387f31c056d9e06194 (diff) | |
| download | bcm5719-llvm-ba4acedb691a7748353d630902cb13afe9897f45.tar.gz bcm5719-llvm-ba4acedb691a7748353d630902cb13afe9897f45.zip | |
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
llvm-svn: 198857
| -rw-r--r-- | clang/lib/CodeGen/CGCleanup.h | 9 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h index 1bd6bba523f..fed75bc9d80 100644 --- a/clang/lib/CodeGen/CGCleanup.h +++ b/clang/lib/CodeGen/CGCleanup.h @@ -194,6 +194,15 @@ public: 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; iterator begin() const { return getHandlers(); } iterator end() const { return getHandlers() + getNumHandlers(); } diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 5acb4537f3d..8a43794281d 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1244,6 +1244,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) { // If the catch was not required, bail out now. if (!CatchScope.hasEHBranches()) { + CatchScope.clearHandlerBlocks(); EHStack.popCatch(); return; } |

