diff options
author | Martin Storsjo <martin@martin.st> | 2019-08-29 08:59:41 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2019-08-29 08:59:41 +0000 |
commit | 357a40ec7c20c075c985079c8591faea1ed79c0d (patch) | |
tree | b45be0da53ad25971209131a2c519352540fd192 | |
parent | e3e8874b89d1732c4d8914bf9556ccf40751a249 (diff) | |
download | bcm5719-llvm-357a40ec7c20c075c985079c8591faea1ed79c0d.tar.gz bcm5719-llvm-357a40ec7c20c075c985079c8591faea1ed79c0d.zip |
[COFF] Fix error handling in ResourceSectionRef
Previously, the expression (Reader.readFoo()) was expanded twice,
triggering asserts as one of the Error types ends up not checked
(and as it was expanded twice, the method would end up called twice
if it failed first).
Differential Revision: https://reviews.llvm.org/D66817
llvm-svn: 370309
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index ceb45bc930d..b3dbf75a5c3 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -1662,9 +1662,12 @@ std::error_code BaseRelocRef::getRVA(uint32_t &Result) const { return std::error_code(); } -#define RETURN_IF_ERROR(E) \ - if (E) \ - return E; +#define RETURN_IF_ERROR(Expr) \ + do { \ + Error E = (Expr); \ + if (E) \ + return std::move(E); \ + } while (0) Expected<ArrayRef<UTF16>> ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) { |