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/VMCore/Core.cpp | |
parent | 95131fcb671f13b931ea3cbb6bbd3fd735f1c5dc (diff) |
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/VMCore/Core.cpp')
-rw-r--r-- | lib/VMCore/Core.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index bbf1375ab0..295d14868f 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -2205,15 +2205,14 @@ LLVMBool LLVMCreateMemoryBufferWithContentsOfFile( LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage) { - MemoryBuffer *MB = MemoryBuffer::getSTDIN(); - if (!MB->getBufferSize()) { - delete MB; - *OutMessage = strdup("stdin is empty."); - return 1; + std::string Error; + if (MemoryBuffer *MB = MemoryBuffer::getSTDIN(&Error)) { + *OutMemBuf = wrap(MB); + return 0; } - *OutMemBuf = wrap(MB); - return 0; + *OutMessage = strdup(Error.c_str()); + return 1; } void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf) { |