[PATCH] D157027: [lld-macho][nfc]Add bounds check before attempting to dereferencing iterators.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 4 06:28:21 PDT 2023
oontvoo updated this revision to Diff 547185.
oontvoo added a comment.
rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157027/new/
https://reviews.llvm.org/D157027
Files:
lld/MachO/Arch/ARM64.cpp
Index: lld/MachO/Arch/ARM64.cpp
===================================================================
--- lld/MachO/Arch/ARM64.cpp
+++ lld/MachO/Arch/ARM64.cpp
@@ -605,11 +605,18 @@
auto secIt = std::prev(llvm::upper_bound(
obj.sections, addr,
[](uint64_t off, const Section *sec) { return off < sec->addr; }));
+ if (secIt < obj.sections.begin() || secIt > obj.sections.end() ||
+ secIt == obj.sections.end())
+ return false;
const Section *sec = *secIt;
auto subsecIt = std::prev(llvm::upper_bound(
sec->subsections, addr - sec->addr,
[](uint64_t off, Subsection subsec) { return off < subsec.offset; }));
+ if (subsecIt < sec->subsections.begin() ||
+ subsecIt > sec->subsections.end() || subsecIt == sec->subsections.end())
+ return false;
+
const Subsection &subsec = *subsecIt;
const ConcatInputSection *isec =
dyn_cast_or_null<ConcatInputSection>(subsec.isec);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157027.547185.patch
Type: text/x-patch
Size: 968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230804/d638a0a9/attachment.bin>
More information about the llvm-commits
mailing list