diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index d6a1f548776..22e12e9d344 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -292,5 +292,6 @@ MemoryBuffer *MemoryBuffer::getSTDIN(std::string *ErrStr) { return 0; } - return getMemBufferCopy(StringRef(&FileData[0], FileData.size()), ""); + FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end(). + return getMemBufferCopy(StringRef(&FileData[0],FileData.size()-1), ""); }