zero-out instruction details, mnemonic & op_str so cs_insn doesnt have garbage in Diet mode
This commit is contained in:
parent
934e180e54
commit
0c07cc9b06
|
@ -232,7 +232,7 @@ static DecodeStatus _getInstruction(cs_struct *ud, MCInst *MI,
|
|||
}
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->arm64, 0, sizeof(cs_arm64));
|
||||
memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
if (ud->big_endian)
|
||||
|
|
|
@ -313,8 +313,9 @@ static DecodeStatus MipsDisassembler_getInstruction(int mode, MCInst *instr,
|
|||
// not enough data
|
||||
return MCDisassembler_Fail;
|
||||
|
||||
if (instr->flat_insn->detail)
|
||||
instr->flat_insn->detail->mips.op_count = 0;
|
||||
if (instr->flat_insn->detail) {
|
||||
memset(instr->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
Result = readInstruction32((unsigned char*)code, &Insn, isBigEndian,
|
||||
mode & CS_MODE_MICRO);
|
||||
|
@ -394,8 +395,9 @@ static DecodeStatus Mips64Disassembler_getInstruction(int mode, MCInst *instr,
|
|||
if (Result == MCDisassembler_Fail)
|
||||
return MCDisassembler_Fail;
|
||||
|
||||
if (instr->flat_insn->detail)
|
||||
instr->flat_insn->detail->mips.op_count = 0;
|
||||
if (instr->flat_insn->detail) {
|
||||
memset(instr->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
// Calling the auto-generated decoder function.
|
||||
Result = decodeInstruction(DecoderTableMips6432, instr, Insn, Address, MRI, mode);
|
||||
|
|
|
@ -346,7 +346,7 @@ static DecodeStatus getInstruction(MCInst *MI,
|
|||
(code[1] << 8) | (code[0] << 0);
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->ppc, 0, offsetof(cs_ppc, operands));
|
||||
memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
result = decodeInstruction_4(DecoderTable32, MI, insn, Address, 4);
|
||||
|
|
|
@ -232,7 +232,7 @@ bool Sparc_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *
|
|||
return MCDisassembler_Fail;
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->sparc, 0, sizeof(cs_sparc));
|
||||
memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
Result = decodeInstruction_4(DecoderTableSparc32, MI, Insn, address,
|
||||
|
|
|
@ -322,7 +322,7 @@ bool SystemZ_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst
|
|||
return MCDisassembler_Fail;
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->sysz, 0, sizeof(cs_sysz));
|
||||
memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
memcpy(Bytes, code, *size);
|
||||
|
|
|
@ -738,7 +738,7 @@ bool XCore_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *
|
|||
}
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->xcore, 0, offsetof(cs_xcore, operands));
|
||||
memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
|
||||
}
|
||||
|
||||
// Calling the auto-generated decoder function.
|
||||
|
|
5
cs.c
5
cs.c
|
@ -460,6 +460,11 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset,
|
|||
// save all the information for non-detailed mode
|
||||
mci.flat_insn = insn_cache;
|
||||
mci.flat_insn->address = offset;
|
||||
#ifdef CAPSTONE_DIET
|
||||
// zero out mnemonic & op_str
|
||||
mci.flat_insn->mnemonic[0] = '\0';
|
||||
mci.flat_insn->op_str[0] = '\0';
|
||||
#endif
|
||||
|
||||
r = handle->disasm(ud, buffer, size, &mci, &insn_size, offset, handle->getinsn_info);
|
||||
if (r) {
|
||||
|
|
Loading…
Reference in New Issue