Skip to content

Commit

Permalink
Prevent leak when jumptable has size hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Goodlett authored and radare committed Feb 13, 2022
1 parent dbc7606 commit d843f07
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions libr/anal/jmptbl.c
Expand Up @@ -455,15 +455,6 @@ R_API bool try_get_jmptbl_info(RAnal *anal, RAnalFunction *fcn, ut64 addr, RAnal
// default case is the jump target of the unconditional jump
*default_case = prev_bb->jump == my_bb->addr ? prev_bb->fail : prev_bb->jump;

RAnalOp tmp_aop = {0};
ut8 *bb_buf = calloc (1, prev_bb->size);
if (!bb_buf) {
return false;
}
// search for a cmp register with a reasonable size
anal->iob.read_at (anal->iob.io, prev_bb->addr, (ut8 *) bb_buf, prev_bb->size);
isValid = false;

RAnalHint *hint = r_anal_hint_get (anal, addr);
if (hint) {
ut64 val = hint->val;
Expand All @@ -474,6 +465,15 @@ R_API bool try_get_jmptbl_info(RAnal *anal, RAnalFunction *fcn, ut64 addr, RAnal
}
}

RAnalOp tmp_aop = {0};
ut8 *bb_buf = calloc (1, prev_bb->size);
if (!bb_buf) {
return false;
}
// search for a cmp register with a reasonable size
anal->iob.read_at (anal->iob.io, prev_bb->addr, (ut8 *) bb_buf, prev_bb->size);
isValid = false;

RRegItem *cmp_reg = NULL;
for (i = prev_bb->ninstr - 1; i >= 0; i--) {
const ut64 prev_pos = r_anal_bb_offset_inst (prev_bb, i);
Expand Down

0 comments on commit d843f07

Please sign in to comment.