[XCOFF] Fix the program abortion issue in XCOFFObjectFile::getSectionContents.
authorEsme-Yi <esme.yi@ibm.com>
Mon, 13 Sep 2021 07:54:33 +0000 (07:54 +0000)
committerEsme-Yi <esme.yi@ibm.com>
Mon, 13 Sep 2021 07:54:33 +0000 (07:54 +0000)
Summary: Use std::move(E) to avoid `Program aborted due to an unhandled Error`

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D109567

llvm/lib/Object/XCOFFObjectFile.cpp

index dfb48e6..dc9dcc0 100644 (file)
@@ -295,8 +295,9 @@ XCOFFObjectFile::getSectionContents(DataRefImpl Sec) const {
 
   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);
 }