Make getSTDIN return null if the standard input is empty, as the header file
documentation implies and as its uses depend.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40939 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 43eb181..0ae5676 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -248,11 +248,13 @@
   
   // Read in all of the data from stdin, we cannot mmap stdin.
   sys::Program::ChangeStdinToBinary();
-  while (size_t ReadBytes = fread(Buffer, 1, 4096*4, stdin))
+  while (size_t ReadBytes = fread(Buffer, sizeof(char), 4096*4, stdin))
     FileData.insert(FileData.end(), Buffer, Buffer+ReadBytes);
-  
+
   FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end().
   size_t Size = FileData.size();
+  if (Size <= 1)
+    return 0;
   MemoryBuffer *B = new STDINBufferFile();
   B->initCopyOf(&FileData[0], &FileData[Size-1]);
   return B;