Skip to content

Commit

Permalink
[X86] Fix to X86LoadValueInjectionRetHardeningPass for possible segfault
Browse files Browse the repository at this point in the history
`MBB.back()` could segfault if `MBB.empty()`. Fixed by checking for `MBB.empty()` in the loop.

Differential Revision: https://reviews.llvm.org/D77584
  • Loading branch information
scottconstable authored and tstellar committed Jun 24, 2020
1 parent d758416 commit ac40e7a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
Expand Up @@ -99,6 +99,9 @@ bool X86LoadValueInjectionRetHardeningPass::runOnMachineFunction(

bool Modified = false;
for (auto &MBB : MF) {
if (MBB.empty())
continue;

MachineInstr &MI = MBB.back();
if (MI.getOpcode() != X86::RETQ)
continue;
Expand Down

0 comments on commit ac40e7a

Please sign in to comment.