fix coverity (#2546)

- cid 514642

- cid 514643

- cid 514644

- cid 514645
This commit is contained in:
billow 2024-11-13 22:05:18 +08:00 committed by GitHub
parent 1ecfb5b042
commit abbf32b431
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -180,6 +180,9 @@ void LoongArch_rewrite_memory_operand(MCInst *MI)
const loongarch_suppl_info *suppl_info =
map_get_suppl_info(MI, loongarch_insns);
if (!suppl_info)
return;
if (suppl_info->memory_access == CS_AC_INVALID) {
// not memory instruction
return;

View File

@ -211,7 +211,7 @@ static DecodeStatus DecodeMR01RegisterClass(MCInst *Inst, uint64_t RegNo,
uint64_t Address,
const void *Decoder)
{
if (RegNo > 2)
if (RegNo >= ARR_SIZE(MR01DecoderTable))
return MCDisassembler_Fail;
unsigned Reg = MR01DecoderTable[RegNo];
@ -970,7 +970,7 @@ static DecodeStatus readInstructionN(const uint8_t *Bytes, size_t BytesLen,
*Insn = 0;
for (unsigned i = 0; i < InstSize; i++)
*Insn |= (Bytes[i] << 8 * i);
*Insn |= (uint64_t)(Bytes[i]) << (8 * i);
*Size = InstSize;
return MCDisassembler_Success;