Minor bugfix/improvement when ninstr == 0 ##analysis

This commit is contained in:
pancake 2023-06-20 19:31:47 +02:00 committed by GitHub
parent 04dc4329a3
commit eb0f571be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -633,6 +633,9 @@ R_API bool r_anal_block_op_starts_at(RAnalBlock *bb, ut64 addr) {
return false;
}
ut64 off = addr - bb->addr;
if (off == 0) {
return true;
}
if (off > UT16_MAX) {
return false;
}

View File

@ -2053,11 +2053,12 @@ R_API RAnalBlock *r_anal_function_bbget_in(RAnal *anal, RAnalFunction *fcn, ut64
}
RListIter *iter;
RAnalBlock *bb;
bool jmpmid = r_anal_is_aligned (anal, addr);
const bool jmpmid = r_anal_is_aligned (anal, addr);
r_list_foreach (fcn->bbs, iter, bb) {
if (addr >= bb->addr && addr < (bb->addr + bb->size)
&& (!anal->opt.jmpmid || !jmpmid || r_anal_block_op_starts_at (bb, addr))) {
return bb;
if (r_anal_block_contains (bb, addr)) {
if ((!anal->opt.jmpmid || !jmpmid || r_anal_block_op_starts_at (bb, addr))) {
return bb;
}
}
}
return NULL;

View File

@ -860,7 +860,7 @@ R_API void r_anal_block_reset(RAnal *a);
R_API RAnalBlock *r_anal_create_block(RAnal *anal, ut64 addr, ut64 size);
static inline bool r_anal_block_contains(RAnalBlock *bb, ut64 addr) {
return addr >= bb->addr && addr < bb->addr + bb->size;
return (addr >= bb->addr) && (addr < bb->addr + bb->size);
}
// Split the block at the given address into two blocks.