diff --git a/cs.c b/cs.c index 435ecec5e..d3d037aa6 100644 --- a/cs.c +++ b/cs.c @@ -324,6 +324,7 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, cs_insn insn_cache[INSN_CACHE_SIZE]; void *total = NULL; size_t total_size = 0; + bool r; if (!handle) { // FIXME: how to handle this case: @@ -342,7 +343,7 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, MCInst_Init(&mci); mci.csh = handle; - bool r = handle->disasm(ud, buffer, size, &mci, &insn_size, offset, handle->getinsn_info); + r = handle->disasm(ud, buffer, size, &mci, &insn_size, offset, handle->getinsn_info); if (r) { SStream ss; SStream_Init(&ss); @@ -368,8 +369,10 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, if (f == ARR_SIZE(insn_cache)) { // resize total to contain newly disasm insns + void *tmp; + total_size += (sizeof(cs_insn) * INSN_CACHE_SIZE); - void *tmp = cs_mem_realloc(total, total_size); + tmp = cs_mem_realloc(total, total_size); if (tmp == NULL) { // insufficient memory cs_mem_free(total); handle->errnum = CS_ERR_MEM;