Fix undefined behaviour reported by the new --enable-expensive-checks option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2007-07-01 03:06:30 +00:00
parent 2672a8e407
commit ea332946d3

View File

@ -251,8 +251,9 @@ MemoryBuffer *MemoryBuffer::getSTDIN() {
while (size_t ReadBytes = fread(Buffer, 1, 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();
MemoryBuffer *B = new STDINBufferFile();
B->initCopyOf(&FileData[0], &FileData[Size]);
B->initCopyOf(&FileData[0], &FileData[Size-1]);
return B;
}