fix: mips array out of bounds

When the incoming data is 4, the index defined by this macro has a crash

Log: mips array out of bounds

Pick-to: 6.8 6.7 6.5
Change-Id: I5acff5479f17e55d5731443d08b0915c701968f6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Liu Zheng 2024-08-08 10:15:07 +08:00 committed by Ulf Hermann
parent 2046497424
commit f83669821b
1 changed files with 1 additions and 1 deletions

View File

@ -228,7 +228,7 @@ void Mips32Opcode::formatJumpEncodingOpcode(uint32_t iOp, uint32_t index, uint32
void Mips32Opcode::formatREGIMMEncodingOpcode(uint8_t rs, uint8_t rt, int16_t imm, uint32_t* opcodePtr)
{
const char *opcodes[] = { "bltz", "bgez", "bltzl", "bgezl" };
if (rt < sizeof(opcodes))
if (rt < 4)
FORMAT_INSTR(OPCODE_FMT "%s, 0x%x", opcodes[rt], registerName(rs), reinterpret_cast<unsigned>(opcodePtr+1) + (imm << 2));
else
FORMAT_INSTR("unknown REGIMM encoding opcode 0x%x", rt);