x86: fix the returned value of cs_disasm_ex() when we have 2 consecutive prefixed instructions. also fix a mem leak bug

This commit is contained in:
Nguyen Anh Quynh 2014-01-27 18:15:28 +08:00
parent a6fc449741
commit 8ce50e4b49

10
cs.c
View File

@ -376,8 +376,16 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset,
break;
} else {
// only combine 1 prefix with regular instruction
if (c == count + 1)
if (c == count + 1) {
// the last insn is redundant
c--;
f--;
// free allocated detail pointer of the last redundant instruction
if (handle->detail)
cs_mem_free(insn_cache[f].detail);
break;
}
}
}
} else {