[PATCH] D157027: [lld-macho][nfc]Add bounds check before attempting to dereferencing iterators.
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 4 20:57:12 PDT 2023
MaskRay added inline comments.
================
Comment at: lld/MachO/Arch/ARM64.cpp:608
[](uint64_t off, const Section *sec) { return off < sec->addr; }));
+ if (secIt < obj.sections.begin() || secIt > obj.sections.end() ||
+ secIt == obj.sections.end())
----------------
`secIt >= obj.sections.end()` should be impossible.
It's better to check whether the `upper_bound` result is out-of-bounds before invoking `std::prev`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157027/new/
https://reviews.llvm.org/D157027
More information about the llvm-commits
mailing list