Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ static unsigned short *make_id2insn(const insn_map *insns, unsigned int size)

unsigned short *cache =
(unsigned short *)cs_mem_calloc(max_id + 1, sizeof(*cache));
if (cache == NULL) {
return NULL;
}

for (i = 1; i < size; i++)
cache[insns[i].id] = i;
Expand All @@ -30,6 +33,9 @@ unsigned short insn_find(const insn_map *insns, unsigned int max,

if (*cache == NULL)
*cache = make_id2insn(insns, max);
if (*cache == NULL) {
return 0;
}

return (*cache)[id];
}
Expand Down
3 changes: 3 additions & 0 deletions arch/AArch64/AArch64Module.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err AArch64_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

AArch64_init(mri);
ud->printer = AArch64_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/ARM/ARMModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err ARM_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

ARM_init(mri);
ARM_getRegName(ud, 0); // use default get_regname
Expand Down
4 changes: 4 additions & 0 deletions arch/MOS65XX/MOS65XXModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ cs_err MOS65XX_global_init(cs_struct *ud)
mos65xx_info *info;

info = cs_mem_malloc(sizeof(*info));
if (info == NULL) {
return CS_ERR_MEM;
}

info->hex_prefix = NULL;
info->cpu_type = MOS65XX_CPU_TYPE_6502;
info->long_m = 0;
Expand Down
3 changes: 3 additions & 0 deletions arch/Mips/MipsModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ cs_err Mips_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

Mips_init(mri);
ud->printer = Mips_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/PowerPC/PPCModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err PPC_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = (MCRegisterInfo *) cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

PPC_init(mri);
ud->printer = PPC_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/RISCV/RISCVModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ cs_err RISCV_global_init(cs_struct * ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

RISCV_init(mri);
ud->printer = RISCV_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/Sparc/SparcModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err Sparc_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

Sparc_init(mri);
ud->printer = Sparc_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/SystemZ/SystemZModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err SystemZ_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

SystemZ_init(mri);
ud->printer = SystemZ_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/TMS320C64x/TMS320C64xModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ cs_err TMS320C64x_global_init(cs_struct *ud)
MCRegisterInfo *mri;

mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

TMS320C64x_init(mri);
ud->printer = TMS320C64x_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/TriCore/TriCoreModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ cs_err TRICORE_global_init(cs_struct *ud)
MCRegisterInfo *mri;

mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

TriCore_init_mri(mri);
ud->printer = TriCore_printInst;
Expand Down
3 changes: 3 additions & 0 deletions arch/X86/X86Module.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err X86_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

X86_init(mri);

Expand Down
3 changes: 3 additions & 0 deletions arch/XCore/XCoreModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cs_err XCore_global_init(cs_struct *ud)
{
MCRegisterInfo *mri;
mri = cs_mem_malloc(sizeof(*mri));
if (mri == NULL) {
return CS_ERR_MEM;
}

XCore_init(mri);
ud->printer = XCore_printInst;
Expand Down
8 changes: 8 additions & 0 deletions cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
// 2. add this instruction if we have not had it yet
if (!tmp) {
tmp = cs_mem_malloc(sizeof(*tmp));
if (!tmp) {
return CS_ERR_MEM;
}
tmp->insn.id = opt->id;
(void)strncpy(tmp->insn.mnemonic, opt->mnemonic, sizeof(tmp->insn.mnemonic) - 1);
tmp->insn.mnemonic[sizeof(tmp->insn.mnemonic) - 1] = '\0';
Expand Down Expand Up @@ -923,6 +926,11 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64
if (handle->detail) {
// allocate memory for @detail pointer
insn_cache->detail = cs_mem_malloc(sizeof(cs_detail));
if (insn_cache->detail == NULL) {
// insufficient memory
handle->errnum = CS_ERR_MEM;
break;
}
} else {
insn_cache->detail = NULL;
}
Expand Down
Loading