[llvm] ea81898 - [XCOFF] Fix the program abortion issue in XCOFFObjectFile::getSectionContents.
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 13 00:55:19 PDT 2021
Author: Esme-Yi
Date: 2021-09-13T07:54:33Z
New Revision: ea81898d0fe2633fdef44822a8578924be4acd6c
URL: https://github.com/llvm/llvm-project/commit/ea81898d0fe2633fdef44822a8578924be4acd6c
DIFF: https://github.com/llvm/llvm-project/commit/ea81898d0fe2633fdef44822a8578924be4acd6c.diff
LOG: [XCOFF] Fix the program abortion issue in XCOFFObjectFile::getSectionContents.
Summary: Use std::move(E) to avoid `Program aborted due to an unhandled Error`
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D109567
Added:
Modified:
llvm/lib/Object/XCOFFObjectFile.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index dfb48e60550f1..dc9dcc0bde3aa 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -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);
}
More information about the llvm-commits
mailing list