Skip to content

Commit

Permalink
Force check of error
Browse files Browse the repository at this point in the history
The passed error needs to be checked.
Otherwise it will force an abort when it is deconstructed, but a
success value.
  • Loading branch information
badboy committed Jul 29, 2016
1 parent 2c16e24 commit a36595e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/rustllvm/ArchiveWrapper.cpp
Expand Up @@ -73,6 +73,9 @@ LLVMRustDestroyArchive(RustArchive *ar) {
struct RustArchiveIterator {
Archive::child_iterator cur;
Archive::child_iterator end;
#if LLVM_VERSION_MINOR >= 9
Error err;
#endif
};

extern "C" RustArchiveIterator*
Expand All @@ -82,15 +85,24 @@ LLVMRustArchiveIteratorNew(RustArchive *ra) {
#if LLVM_VERSION_MINOR <= 8
rai->cur = ar->child_begin();
#else
Error err;
rai->cur = ar->child_begin(err);
rai->cur = ar->child_begin(rai->err);
if (rai->err) {
LLVMRustSetLastError(toString(std::move(rai->err)).c_str());
return NULL;
}
#endif
rai->end = ar->child_end();
return rai;
}

extern "C" const Archive::Child*
LLVMRustArchiveIteratorNext(RustArchiveIterator *rai) {
#if LLVM_VERSION_MINOR >= 9
if (rai->err) {
LLVMRustSetLastError(toString(std::move(rai->err)).c_str());
return NULL;
}
#endif
if (rai->cur == rai->end)
return NULL;
#if LLVM_VERSION_MINOR == 8
Expand Down

0 comments on commit a36595e

Please sign in to comment.