Skip to content

Commit 357a40e

Browse files
committed
[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
1 parent e3e8874 commit 357a40e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Object/COFFObjectFile.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1662,9 +1662,12 @@ std::error_code BaseRelocRef::getRVA(uint32_t &Result) const {
16621662
return std::error_code();
16631663
}
16641664

1665-
#define RETURN_IF_ERROR(E) \
1666-
if (E) \
1667-
return E;
1665+
#define RETURN_IF_ERROR(Expr) \
1666+
do { \
1667+
Error E = (Expr); \
1668+
if (E) \
1669+
return std::move(E); \
1670+
} while (0)
16681671

16691672
Expected<ArrayRef<UTF16>>
16701673
ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) {

0 commit comments

Comments
 (0)