mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-03 11:50:02 +00:00
Initialize RAsmOp and update acode->bin after hex (#11178)
This commit is contained in:
parent
d8a9bfba35
commit
bc70bc25eb
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 ();
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user