diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2007-07-01 03:06:30 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2007-07-01 03:06:30 +0000 |
commit | ea332946d3577cc75422a1ad0cbce9321e9e8c59 (patch) | |
tree | 2d98081aade1b3a0f0ef7cc568601bc66454bb2c /lib | |
parent | 2672a8e4077a537d91d3c829d146e33104b253c1 (diff) | |
download | external_llvm-ea332946d3577cc75422a1ad0cbce9321e9e8c59.zip external_llvm-ea332946d3577cc75422a1ad0cbce9321e9e8c59.tar.gz external_llvm-ea332946d3577cc75422a1ad0cbce9321e9e8c59.tar.bz2 |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/MemoryBuffer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index 0e85702..43eb181 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -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; } |