fix NULL deref on failed strbuf_new and memory leak in r_asm_mdisassemble (#7163)

This commit is contained in:
Thomas Ilsche 2017-03-29 00:44:36 +02:00 committed by radare
parent 8edcc53a18
commit 1a72b58daa

View File

@ -562,11 +562,10 @@ R_API RAsmCode* r_asm_mdisassemble(RAsm *a, const ut8 *buf, int len) {
return r_asm_code_free (acode);
}
r_hex_bin2str (buf, len, acode->buf_hex);
if (!(acode->buf_asm = malloc (4))) {
if (!(buf_asm = r_strbuf_new (NULL))) {
return r_asm_code_free (acode);
}
buf_asm = r_strbuf_new (NULL);
for (idx = ret = slen = 0, acode->buf_asm[0] = '\0'; idx < len; idx += ret) {
for (idx = ret = slen = 0; idx < len; idx += ret) {
r_asm_set_pc (a, pc + idx);
ret = r_asm_disassemble (a, &op, buf + idx, len - idx);
if (ret < 1) {