mips & xcore: some safety guards to make sure printOperand() do not overflow Operands[] for some unknown reasons
diff --git a/arch/Mips/MipsInstPrinter.c b/arch/Mips/MipsInstPrinter.c
index 7bd6991..362d8ff 100644
--- a/arch/Mips/MipsInstPrinter.c
+++ b/arch/Mips/MipsInstPrinter.c
@@ -169,8 +169,9 @@
mnem = printAliasInstr(MI, O, info);
if (!mnem) {
mnem = printAlias(MI, O);
- if (!mnem)
+ if (!mnem) {
printInstruction(MI, O, NULL);
+ }
}
if (mnem) {
@@ -182,7 +183,12 @@
static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
{
- MCOperand *Op = MCInst_getOperand(MI, OpNo);
+ MCOperand *Op;
+
+ if (OpNo >= MI->size)
+ return;
+
+ Op = MCInst_getOperand(MI, OpNo);
if (MCOperand_isReg(Op)) {
unsigned int reg = MCOperand_getReg(Op);
printRegName(O, reg);
diff --git a/arch/XCore/XCoreInstPrinter.c b/arch/XCore/XCoreInstPrinter.c
index 2c93abf..259ca3d 100644
--- a/arch/XCore/XCoreInstPrinter.c
+++ b/arch/XCore/XCoreInstPrinter.c
@@ -237,6 +237,9 @@
static void printOperand(MCInst *MI, int OpNum, SStream *O)
{
+ if (OpNum >= MI->size)
+ return;
+
_printOperand(MI, MCInst_getOperand(MI, OpNum), O);
}