Skip to content

Commit a2c62c7

Browse files
scottconstableAdrian Cruceru
authored and
Adrian Cruceru
committed
[X86] Fix to X86LoadValueInjectionRetHardeningPass for possible segfault
`MBB.back()` could segfault if `MBB.empty()`. Fixed by checking for `MBB.empty()` in the loop. Differential Revision: https://reviews.llvm.org/D77584 (cherry picked from commit 0505181)
1 parent 6810e22 commit a2c62c7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ bool X86LoadValueInjectionRetHardeningPass::runOnMachineFunction(
9999

100100
bool Modified = false;
101101
for (auto &MBB : MF) {
102+
if (MBB.empty())
103+
continue;
104+
102105
MachineInstr &MI = MBB.back();
103106
if (MI.getOpcode() != X86::RETQ)
104107
continue;

0 commit comments

Comments
 (0)