[PATCH] D24659: Trying to fix Mangler memory leak in TargetLoweringObjectFile.
Eric Liu via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 16 04:56:57 PDT 2016
ioeric created this revision.
ioeric added a reviewer: echristo.
ioeric added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.
`TargetLoweringObjectFile` can be re-used and thus `TargetLoweringObjectFile::Initialize()`
can be called multiple times causing `Mang` pointer memory leak.
https://reviews.llvm.org/D24659
Files:
include/llvm/Target/TargetLoweringObjectFile.h
lib/Target/TargetLoweringObjectFile.cpp
Index: lib/Target/TargetLoweringObjectFile.cpp
===================================================================
--- lib/Target/TargetLoweringObjectFile.cpp
+++ lib/Target/TargetLoweringObjectFile.cpp
@@ -43,6 +43,8 @@
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
const TargetMachine &TM) {
Ctx = &ctx;
+ // `Initialize` can be called more than once.
+ if (Mang != nullptr) delete Mang;
Mang = new Mangler();
InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(),
TM.getCodeModel(), *Ctx);
Index: include/llvm/Target/TargetLoweringObjectFile.h
===================================================================
--- include/llvm/Target/TargetLoweringObjectFile.h
+++ include/llvm/Target/TargetLoweringObjectFile.h
@@ -38,7 +38,7 @@
MCContext *Ctx;
/// Name-mangler for global names.
- Mangler *Mang;
+ Mangler *Mang = nullptr;
TargetLoweringObjectFile(
const TargetLoweringObjectFile&) = delete;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24659.71616.patch
Type: text/x-patch
Size: 1026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160916/5dc1a743/attachment.bin>
More information about the llvm-commits
mailing list