[PATCH] D109567: [XCOFF] Fix the program abortion issue.

Esme Yi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 22:29:22 PDT 2021


Esme created this revision.
Esme added reviewers: jhenderson, shchenz, Higuoxing.
Herald added a subscriber: hiraditya.
Esme requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Use `std::move(E)` to avoid `Program aborted due to an unhandled Error:..`
This is found during testing the error paths in D98003 <https://reviews.llvm.org/D98003>.
See the error case 1 in llvm/test/tools/obj2yaml/XCOFF/invalid.yaml of D98003 <https://reviews.llvm.org/D98003>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109567

Files:
  llvm/lib/Object/XCOFFObjectFile.cpp


Index: llvm/lib/Object/XCOFFObjectFile.cpp
===================================================================
--- llvm/lib/Object/XCOFFObjectFile.cpp
+++ llvm/lib/Object/XCOFFObjectFile.cpp
@@ -293,10 +293,11 @@
   else
     OffsetToRaw = toSection32(Sec)->FileOffsetToRawData;
 
-  const uint8_t * ContentStart = base() + OffsetToRaw;
+  const uint8_t *ContentStart = base() + OffsetToRaw;
   uint64_t SectionSize = getSectionSize(Sec);
-  if (checkOffset(Data, reinterpret_cast<uintptr_t>(ContentStart), SectionSize))
-    return make_error<BinaryError>();
+  if (Error E = Binary::checkOffset(
+          Data, reinterpret_cast<uintptr_t>(ContentStart), SectionSize))
+    return std::move(E);
 
   return makeArrayRef(ContentStart,SectionSize);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109567.371785.patch
Type: text/x-patch
Size: 753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210910/504e796a/attachment.bin>


More information about the llvm-commits mailing list