diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-15 01:39:31 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-15 01:39:31 +0000 |
commit | 11a4fa452305eeaeaaaf9c4fd83d043da081bd11 (patch) | |
tree | cad0380a01d8c5f5c037a89197cd6e788e047c88 /lib | |
parent | 652199961a8acf3314b15bb3d5133e8a9a56b615 (diff) | |
download | external_llvm-11a4fa452305eeaeaaaf9c4fd83d043da081bd11.zip external_llvm-11a4fa452305eeaeaaaf9c4fd83d043da081bd11.tar.gz external_llvm-11a4fa452305eeaeaaaf9c4fd83d043da081bd11.tar.bz2 |
Fix undefined behavior: don't perform array indexing through a potentially null
pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/MachineVerifier.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/CodeGen/MachineVerifier.cpp b/lib/CodeGen/MachineVerifier.cpp index 172402e..f745b41 100644 --- a/lib/CodeGen/MachineVerifier.cpp +++ b/lib/CodeGen/MachineVerifier.cpp @@ -681,10 +681,10 @@ void MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) { const MachineInstr *MI = MO->getParent(); const MCInstrDesc &MCID = MI->getDesc(); - const MCOperandInfo &MCOI = MCID.OpInfo[MONum]; // The first MCID.NumDefs operands must be explicit register defines if (MONum < MCID.getNumDefs()) { + const MCOperandInfo &MCOI = MCID.OpInfo[MONum]; if (!MO->isReg()) report("Explicit definition must be a register", MO, MONum); else if (!MO->isDef() && !MCOI.isOptionalDef()) @@ -692,6 +692,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) { else if (MO->isImplicit()) report("Explicit definition marked as implicit", MO, MONum); } else if (MONum < MCID.getNumOperands()) { + const MCOperandInfo &MCOI = MCID.OpInfo[MONum]; // Don't check if it's the last operand in a variadic instruction. See, // e.g., LDM_RET in the arm back end. if (MO->isReg() && |