Skip to content

Commit a36595e

Browse files
committed
Force check of error
The passed error needs to be checked. Otherwise it will force an abort when it is deconstructed, but a success value.
1 parent 2c16e24 commit a36595e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/rustllvm/ArchiveWrapper.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ LLVMRustDestroyArchive(RustArchive *ar) {
7373
struct RustArchiveIterator {
7474
Archive::child_iterator cur;
7575
Archive::child_iterator end;
76+
#if LLVM_VERSION_MINOR >= 9
77+
Error err;
78+
#endif
7679
};
7780

7881
extern "C" RustArchiveIterator*
@@ -82,15 +85,24 @@ LLVMRustArchiveIteratorNew(RustArchive *ra) {
8285
#if LLVM_VERSION_MINOR <= 8
8386
rai->cur = ar->child_begin();
8487
#else
85-
Error err;
86-
rai->cur = ar->child_begin(err);
88+
rai->cur = ar->child_begin(rai->err);
89+
if (rai->err) {
90+
LLVMRustSetLastError(toString(std::move(rai->err)).c_str());
91+
return NULL;
92+
}
8793
#endif
8894
rai->end = ar->child_end();
8995
return rai;
9096
}
9197

9298
extern "C" const Archive::Child*
9399
LLVMRustArchiveIteratorNext(RustArchiveIterator *rai) {
100+
#if LLVM_VERSION_MINOR >= 9
101+
if (rai->err) {
102+
LLVMRustSetLastError(toString(std::move(rai->err)).c_str());
103+
return NULL;
104+
}
105+
#endif
94106
if (rai->cur == rai->end)
95107
return NULL;
96108
#if LLVM_VERSION_MINOR == 8

0 commit comments

Comments
 (0)