check malloc return value

This commit is contained in:
Edward Williamson 2014-12-14 20:45:19 -05:00
parent b53a59af53
commit f1e497502c
1 changed files with 6 additions and 0 deletions

6
cs.c
View File

@ -447,6 +447,12 @@ size_t cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, si
total_size = sizeof(cs_insn) * cache_size;
total = cs_mem_malloc(total_size);
if (total == NULL)
{
//malloc failed
handle->errnum = CS_ERR_MEM;
return 0;
}
insn_cache = total;
while (size > 0) {