Index: llvm/trunk/lib/Object/Object.cpp =================================================================== --- llvm/trunk/lib/Object/Object.cpp +++ llvm/trunk/lib/Object/Object.cpp @@ -64,9 +64,10 @@ ErrorOr> ObjOrErr( ObjectFile::createObjectFile(Buf->getMemBufferRef())); std::unique_ptr Obj; - if (ObjOrErr) - Obj = std::move(ObjOrErr.get()); - auto *Ret = new OwningBinary(std::move(Obj), std::move(Buf)); + if (!ObjOrErr) + return nullptr; + + auto *Ret = new OwningBinary(std::move(ObjOrErr.get()), std::move(Buf)); return wrap(Ret); } Index: llvm/trunk/test/Bindings/llvm-c/objectfile.ll =================================================================== --- llvm/trunk/test/Bindings/llvm-c/objectfile.ll +++ llvm/trunk/test/Bindings/llvm-c/objectfile.ll @@ -0,0 +1,2 @@ +; RUN: not llvm-c-test --object-list-sections < /dev/null +; This used to cause a segfault