mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-04 02:18:46 +00:00
Trying to fix Mangler memory leak in TargetLoweringObjectFile.
Summary: `TargetLoweringObjectFile` can be re-used and thus `TargetLoweringObjectFile::Initialize()` can be called multiple times causing `Mang` pointer memory leak. Reviewers: echristo Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D24659 llvm-svn: 281718
This commit is contained in:
parent
f1fcfdd6f0
commit
f6a6007dcc
@ -38,7 +38,7 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
|
||||
MCContext *Ctx;
|
||||
|
||||
/// Name-mangler for global names.
|
||||
Mangler *Mang;
|
||||
Mangler *Mang = nullptr;
|
||||
|
||||
TargetLoweringObjectFile(
|
||||
const TargetLoweringObjectFile&) = delete;
|
||||
|
@ -43,6 +43,8 @@ using namespace llvm;
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user