Skip to content

Commit 0505181

Browse files
scottconstabletopperc
authored andcommitted
[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
1 parent aa4b37b commit 0505181

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp

Lines changed: 3 additions & 0 deletions
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)