Initialize RAsmOp and update acode->bin after hex (#11178)

This commit is contained in:
radare 2018-08-22 03:28:44 +02:00 committed by GitHub
parent d8a9bfba35
commit bc70bc25eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -713,7 +713,7 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
return r_asm_code_free (acode);
}
*acode->buf_hex = 0;
if (!(acode->buf = malloc (64))) {
if (!(acode->buf = calloc (1, 64))) {
return r_asm_code_free (acode);
}
lbuf = strdup (buf);
@ -1009,6 +1009,7 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
}
}
free (lbuf);
r_hex_str2bin (acode->buf_hex, acode->buf);
return acode;
}

View File

@ -1405,21 +1405,23 @@ static int cmd_write(void *data, const char *input) {
case 'o': // "wao"
if (input[2] == ' ') {
char *op = r_str_trim (strdup (input + 3));
r_core_hack (core, op);
free (op);
if (op) {
r_core_hack (core, op);
free (op);
}
} else {
r_core_hack_help (core);
}
break;
case ' ':
case '*': {
const char *file = input[1]=='*'? input+2: input+1;
const char *file = input[1]=='*'? input + 2: input + 1;
RAsmCode *acode;
r_asm_set_pc (core->assembler, core->offset);
acode = r_asm_massemble (core->assembler, file);
if (acode) {
if (input[1]=='*') {
cmd_write_hexpair(core, acode->buf_hex);
if (input[1] == '*') {
cmd_write_hexpair (core, acode->buf_hex);
} else {
if (!r_core_write_at (core, core->offset, acode->buf, acode->len)) {
cmd_write_fail ();

View File

@ -2558,7 +2558,7 @@ R_API int r_core_seek_align(RCore *core, ut64 align, int times) {
}
R_API char *r_core_op_str(RCore *core, ut64 addr) {
RAsmOp op;
RAsmOp op = {0};
ut8 buf[64];
int ret;
r_asm_set_pc (core->assembler, addr);