[llvm-commits] [llvm] r160075 - /llvm/trunk/lib/Support/MemoryBuffer.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Jul 11 13:59:20 PDT 2012
Author: akirtzidis
Date: Wed Jul 11 15:59:20 2012
New Revision: 160075
URL: http://llvm.org/viewvc/llvm-project?rev=160075&view=rev
Log:
In MemoryBuffer::getOpenFile() don't verify that the mmap'ed
file buffer is null-terminated.
If the file is smaller than we thought, mmap will not allow dereferencing
past the pages that are enough to cover the actual file size,
even though we asked for a larger address range.
rdar://11612916
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=160075&r1=160074&r2=160075&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Jul 11 15:59:20 2012
@@ -313,16 +313,6 @@
RealMapOffset)) {
result.reset(GetNamedBuffer<MemoryBufferMMapFile>(
StringRef(Pages + Delta, MapSize), Filename, RequiresNullTerminator));
-
- if (RequiresNullTerminator && result->getBufferEnd()[0] != '\0') {
- // There could be a racing issue that resulted in the file being larger
- // than the FileSize passed by the caller. We already have an assertion
- // for this in MemoryBuffer::init() but have a runtime guarantee that
- // the buffer will be null-terminated here, so do a copy that adds a
- // null-terminator.
- result.reset(MemoryBuffer::getMemBufferCopy(result->getBuffer(),
- Filename));
- }
return error_code::success();
}
}
More information about the llvm-commits
mailing list