Skip to content

Commit 506a454

Browse files
committed
a cagar a la via
1 parent 7c5553a commit 506a454

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

libr/core/casm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ static int is_hit_inrange(RCoreAsmHit *hit, ut64 start_range, ut64 end_range){
485485
R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
486486
RAsmOp op;
487487
// if (n > core->blocksize) n = core->blocksize;
488-
ut64 at;
489488
ut32 idx = 0, hit_count;
490489
int numinstr, asmlen, ii;
491490
const int addrbytes = core->io->addrbytes;
@@ -494,8 +493,7 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
494493
if (!hits) {
495494
return NULL;
496495
}
497-
498-
len = R_MIN (len - len % addrbytes, addrbytes * addr);
496+
len = R_MIN (len - (len % addrbytes), addrbytes * addr);
499497
if (len < 1) {
500498
r_list_free (hits);
501499
return NULL;
@@ -509,7 +507,7 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
509507
free (buf);
510508
return NULL;
511509
}
512-
if (!r_io_read_at (core->io, addr - len / addrbytes, buf, len)) {
510+
if (!r_io_read_at (core->io, addr - (len / addrbytes), buf, len)) {
513511
r_list_free (hits);
514512
free (buf);
515513
return NULL;
@@ -536,7 +534,9 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
536534
break;
537535
}
538536
}
539-
at = addr - idx / addrbytes;
537+
538+
ut64 at = addr - idx / addrbytes;
539+
540540
r_asm_set_pc (core->rasm, at);
541541
for (hit_count = 0; hit_count < n; hit_count++) {
542542
int instrlen = r_asm_disassemble (core->rasm, &op,

libr/core/cmd_print.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,9 +1221,11 @@ static void cmd_pdj(RCore *core, const char *arg, ut8* block, int len) {
12211221
}
12221222
pj_a (pj);
12231223
ut8 *data = malloc (core->blocksize);
1224-
memcpy (data, core->block, core->blocksize);
1225-
r_core_print_disasm_json (core, core->offset, data, core->blocksize, nblines, pj);
1226-
free (data);
1224+
if (data) {
1225+
memcpy (data, core->block, core->blocksize);
1226+
r_core_print_disasm_json (core, core->offset, data, core->blocksize, nblines, pj);
1227+
free (data);
1228+
}
12271229
pj_end (pj);
12281230
r_cons_println (pj_string (pj));
12291231
pj_free (pj);
@@ -5947,7 +5949,7 @@ static int cmd_print(void *data, const char *input) {
59475949
pd_result = false;
59485950
}
59495951
break;
5950-
case 'j': // pdj
5952+
case 'j': // "pdj"
59515953
processed_cmd = true;
59525954
if (*input == 'D') {
59535955
cmd_pDj (core, input + 2);
@@ -6039,7 +6041,7 @@ static int cmd_print(void *data, const char *input) {
60396041
bs1 - (bs - bs % addrbytes));
60406042
}
60416043
core->num->value = r_core_print_disasm (core,
6042-
off, block1,
6044+
addr - bs1, block1,
60436045
R_MAX (bs, bs1), l, 0, NULL,
60446046
false, formatted_json, NULL,
60456047
NULL);

libr/core/disasm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6271,7 +6271,6 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
62716271
eprintf ("Too many backward instructions\n");
62726272
return false;
62736273
}
6274-
62756274
if (r_core_prevop_addr (core, core->offset, nb_opcodes, &addr)) {
62766275
nbytes = old_offset - addr;
62776276
} else if (!r_core_asm_bwdis_len (core, &nbytes, &addr, nb_opcodes)) {
@@ -6291,10 +6290,10 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
62916290
count = R_MIN (nb_bytes, nbytes);
62926291
if (count > 0) {
62936292
r_io_read_at (core->io, addr, buf, count);
6294-
r_io_read_at (core->io, addr+count, buf+count, nb_bytes-count);
6293+
r_io_read_at (core->io, addr + count, buf + count, nb_bytes-count);
62956294
} else {
62966295
if (nb_bytes > 0) {
6297-
memset (buf, 0xff, nb_bytes);
6296+
memset (buf, core->io->Oxff, nb_bytes);
62986297
}
62996298
}
63006299
} else {

0 commit comments

Comments
 (0)