From 863f84648f937683a88d09877c51d6257165bed6 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Wed, 20 Apr 2011 00:43:34 +0000 Subject: [PATCH] Made the MC disassembler check before accessing MCInst operands for ARM. This allows it to be more tolerant of malformed MCInsts or incorrect instruction metadata. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129840 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCDisassembler/EDOperand.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/MC/MCDisassembler/EDOperand.cpp b/lib/MC/MCDisassembler/EDOperand.cpp index 04b21cb3592..492bb08f336 100644 --- a/lib/MC/MCDisassembler/EDOperand.cpp +++ b/lib/MC/MCDisassembler/EDOperand.cpp @@ -198,15 +198,24 @@ int EDOperand::evaluate(uint64_t &result, default: return -1; case kOperandTypeImmediate: + if (!Inst.Inst->getOperand(MCOpIndex).isImm()) + return -1; + result = Inst.Inst->getOperand(MCOpIndex).getImm(); return 0; case kOperandTypeRegister: { + if (!Inst.Inst->getOperand(MCOpIndex).isReg()) + return -1; + unsigned reg = Inst.Inst->getOperand(MCOpIndex).getReg(); return callback(&result, reg, arg); } case kOperandTypeARMBranchTarget: { + if (!Inst.Inst->getOperand(MCOpIndex).isImm()) + return -1; + int64_t displacement = Inst.Inst->getOperand(MCOpIndex).getImm(); uint64_t pcVal; -- 2.34.1