[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
Wed Aug 9 10:16:19 PDT 2023


oontvoo updated this revision to Diff 548665.
oontvoo marked an inline comment as done.
oontvoo added a comment.

updated diff


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
@@ -602,11 +602,15 @@
         addr < sectionAddr + section->getSize())
       return true;
 
+    if (obj.sections.empty())
+      return false;
     auto secIt = std::prev(llvm::upper_bound(
         obj.sections, addr,
         [](uint64_t off, const Section *sec) { return off < sec->addr; }));
     const Section *sec = *secIt;
 
+    if (sec->subsections.empty())
+      return false;
     auto subsecIt = std::prev(llvm::upper_bound(
         sec->subsections, addr - sec->addr,
         [](uint64_t off, Subsection subsec) { return off < subsec.offset; }));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157027.548665.patch
Type: text/x-patch
Size: 724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/55027f99/attachment.bin>


More information about the llvm-commits mailing list