Skip to content

Commit

Permalink
Improve addr wrap support in r_itv as stated by the comment ##io
Browse files Browse the repository at this point in the history
* as a test create an itv starting at ut64_max - 1 with size of 8. then check if 4 is included
  • Loading branch information
condret authored Aug 17, 2024
1 parent 19b7eeb commit a05afbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libr/include/r_util/r_itv.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ static inline bool r_itv_eq(RInterval itv, RInterval itv2) {
return itv.addr == itv2.addr && itv.size == itv2.size;
}

// Returns true if itv contained addr
// Returns true if itv contains addr
static inline bool r_itv_contain(RInterval itv, ut64 addr) {
const ut64 end = itv.addr + itv.size;
return itv.addr <= addr && (!end || addr < end);
if (R_UNLIKELY (end < itv.addr)) {
RInterval _itv = {end, itv.addr - end};
return !r_itv_contain (_itv, addr);
}
return itv.addr <= addr && addr < end;
}

// Returns true if x is a subset of itv
Expand Down

0 comments on commit a05afbd

Please sign in to comment.