From e6cbc202abf9911609f2f61dcd2b0e917b05284d Mon Sep 17 00:00:00 2001 From: billow Date: Tue, 12 Nov 2024 00:21:50 +0800 Subject: [PATCH] fix coverity - cid 514642 - cid 514643 - cid 514644 - cid 514645 --- arch/LoongArch/LoongArchMapping.c | 3 +++ arch/Xtensa/XtensaDisassembler.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/LoongArch/LoongArchMapping.c b/arch/LoongArch/LoongArchMapping.c index b32e42c685..e8a3746832 100644 --- a/arch/LoongArch/LoongArchMapping.c +++ b/arch/LoongArch/LoongArchMapping.c @@ -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; diff --git a/arch/Xtensa/XtensaDisassembler.c b/arch/Xtensa/XtensaDisassembler.c index 3f53a7bde2..0fb216758c 100644 --- a/arch/Xtensa/XtensaDisassembler.c +++ b/arch/Xtensa/XtensaDisassembler.c @@ -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;