summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2019-08-29 08:59:41 +0000
committerMartin Storsjo <martin@martin.st>2019-08-29 08:59:41 +0000
commit357a40ec7c20c075c985079c8591faea1ed79c0d (patch)
treeb45be0da53ad25971209131a2c519352540fd192
parente3e8874b89d1732c4d8914bf9556ccf40751a249 (diff)
downloadbcm5719-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.cpp9
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) {
OpenPOWER on IntegriCloud