Skip to content

Commit c994da9

Browse files
committed
Fix off-by-one error in address lookup
1 parent 955a921 commit c994da9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

elf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Object::getSegmentForAddress(Off a) const
150150

151151
auto pos = std::lower_bound(hdrs.begin(), hdrs.end(), a,
152152
[] (const Elf::Phdr &header, Elf::Off addr) {
153-
return header.p_vaddr + header.p_memsz < addr; });
153+
return header.p_vaddr + header.p_memsz <= addr; });
154154
if (pos != hdrs.end() && pos->p_vaddr <= a) {
155155
lastSegmentForAddress = &*pos;
156156
return lastSegmentForAddress;

0 commit comments

Comments
 (0)