diff options
author | Dan Gohman <gohman@apple.com> | 2010-05-27 17:31:51 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-05-27 17:31:51 +0000 |
commit | 30377e780918aacda1befa47054c61b0155c194c (patch) | |
tree | 0433fbc0a31e3ee419d7b86770778234d391f787 /lib/Linker | |
parent | 95131fcb671f13b931ea3cbb6bbd3fd735f1c5dc (diff) | |
download | external_llvm-30377e780918aacda1befa47054c61b0155c194c.zip external_llvm-30377e780918aacda1befa47054c61b0155c194c.tar.gz external_llvm-30377e780918aacda1befa47054c61b0155c194c.tar.bz2 |
Add basic error checking to MemoryBuffer::getSTDIN.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkItems.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp index f0c7b68..1be2bec 100644 --- a/lib/Linker/LinkItems.cpp +++ b/lib/Linker/LinkItems.cpp @@ -160,16 +160,17 @@ bool Linker::LinkInFile(const sys::Path &File, bool &is_native) { // Check for a file of name "-", which means "read standard input" if (File.str() == "-") { std::auto_ptr<Module> M; - MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(); - if (!Buffer->getBufferSize()) { - delete Buffer; - Error = "standard input is empty"; - } else { - M.reset(ParseBitcodeFile(Buffer, Context, &Error)); - delete Buffer; - if (M.get()) - if (!LinkInModule(M.get(), &Error)) - return false; + if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(&Error)) { + if (!Buffer->getBufferSize()) { + delete Buffer; + Error = "standard input is empty"; + } else { + M.reset(ParseBitcodeFile(Buffer, Context, &Error)); + delete Buffer; + if (M.get()) + if (!LinkInModule(M.get(), &Error)) + return false; + } } return error("Cannot link stdin: " + Error); } |