Fix RReg.arena.size issue caused by missing parenthesis in BITS2BYTES

This commit is contained in:
pancake 2014-07-03 11:54:58 +02:00
parent 88687d9da4
commit b6850182b9
3 changed files with 13 additions and 1 deletions

View File

@ -727,6 +727,14 @@ void cmd_anal_reg(RCore *core, const char *str) {
r_cons_printf ("0x%08"PFMT64x"\n", off);
} else ar_show_help (core);
break;
case 'S':
{
int sz;
ut8 *buf = r_reg_get_bytes (
core->anal->reg, R_REG_TYPE_GPR, &sz);
r_cons_printf ("%d\n", sz);
}
break;
case 'b':
{ // WORK IN PROGRESS // DEBUG COMMAND
int len;

View File

@ -168,7 +168,7 @@ typedef void (*PrintfCallback)(const char *str, ...);
#endif
#endif
#define BITS2BYTES(x) ((x/8)+((x%8)?1:0))
#define BITS2BYTES(x) (((x)/8)+(((x)%8)?1:0))
#define ZERO_FILL(x) memset (&x, 0, sizeof (x))
#define R_NEWS0(x,y) (x*)memset (malloc(sizeof(x)*y), 0, sizeof(x)*y);
#define R_NEWS(x,y) (x*)malloc(sizeof(x)*y)

View File

@ -7,6 +7,8 @@ R_API ut8* r_reg_get_bytes(RReg *reg, int type, int *size) {
RRegArena *arena;
int i, sz, osize;
ut8 *buf;
if (size)
*size = 0;
if (type == -1) {
/* serialize ALL register types in a single buffer */
// owned buffer is returned
@ -113,6 +115,8 @@ R_API int r_reg_fit_arena(RReg *reg) {
arena = reg->regset[i].arena;
newsize = 0;
r_list_foreach (reg->regset[i].regs, iter, r) {
int regsize_in_bytes = r->size / 8;
// XXX: bits2bytes doesnt seems to work fine
size = BITS2BYTES (r->offset+r->size);
newsize = R_MAX (size, newsize);
}