llvm::mk_object_file should really return an option, since the underlying LLVM function can fail. Fixes a crash on OS X when rust has bad dylibs within eyeshot.
This commit is contained in:
parent
ba57ec24ea
commit
07bab92970
2 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
import std::{vec, str};
|
||||
import std::{vec, str, option};
|
||||
import std::str::sbuf;
|
||||
|
||||
import llvm::{ModuleRef, ContextRef, TypeRef, TypeHandleRef, ValueRef,
|
||||
|
@ -1057,9 +1057,10 @@ resource object_file_res(ObjectFile: ObjectFileRef) {
|
|||
|
||||
type object_file = {llof: ObjectFileRef, dtor: @object_file_res};
|
||||
|
||||
fn mk_object_file(llmb: MemoryBufferRef) -> object_file {
|
||||
fn mk_object_file(llmb: MemoryBufferRef) -> option::t<object_file> {
|
||||
let llof = llvm::LLVMCreateObjectFile(llmb);
|
||||
ret {llof: llof, dtor: @object_file_res(llof)};
|
||||
if llof as int == 0 { ret option::none::<object_file>; }
|
||||
ret option::some::<object_file>({llof: llof, dtor: @object_file_res(llof)});
|
||||
}
|
||||
|
||||
/* Memory-managed interface to section iterators. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue