diff options
author | abhishek-kaushik22 <abhishek.kaushik@intel.com> | 2024-09-23 17:11:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 17:11:56 +0800 |
commit | f28a0355364b9f09fa3d47720af4cf7431721de6 (patch) | |
tree | fed6ba0b792cfa72a4cfc336e15fc8e83da08e95 /llvm/lib/CodeGen/LLVMTargetMachine.cpp | |
parent | 0b0a37e158bcf6d0667b4744b3d335f91578e0c9 (diff) | |
download | llvm-f28a0355364b9f09fa3d47720af4cf7431721de6.zip llvm-f28a0355364b9f09fa3d47720af4cf7431721de6.tar.gz llvm-f28a0355364b9f09fa3d47720af4cf7431721de6.tar.bz2 |
Fix memory leak in LLVMTargetMachine.cpp (#109610)
Because `MAB` is a raw pointer, it could potentially leak memory because
of the `||` in the null check.
Diffstat (limited to 'llvm/lib/CodeGen/LLVMTargetMachine.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LLVMTargetMachine.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index d0dfafe..4ff2205 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -259,9 +259,11 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx, const MCRegisterInfo &MRI = *getMCRegisterInfo(); std::unique_ptr<MCCodeEmitter> MCE( getTarget().createMCCodeEmitter(*getMCInstrInfo(), *Ctx)); + if (!MCE) + return true; MCAsmBackend *MAB = getTarget().createMCAsmBackend(STI, MRI, Options.MCOptions); - if (!MCE || !MAB) + if (!MAB) return true; const Triple &T = getTargetTriple(); |