aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/MemoryBuffer.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-03-14 00:20:10 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-03-14 00:20:10 +0000
commitcc3a595ab938352f3acf8652c5858ddf879524a5 (patch)
tree1f67c816387fd6a44ecf54063cc9c283b06642a3 /lib/Support/MemoryBuffer.cpp
parent64a0a33307723957bf2f15e3181a290853c6f833 (diff)
[Support] Fix lifetime of file descriptors when using MemoryBuffer.
Clients of MemoryBuffer::getOpenFile expect it not to take ownership of the file descriptor passed in. So don't. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/MemoryBuffer.cpp')
-rw-r--r--lib/Support/MemoryBuffer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 1c354be2e0..8042237253 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -206,7 +206,7 @@ class MemoryBufferMMapFile : public MemoryBuffer {
public:
MemoryBufferMMapFile(bool RequiresNullTerminator, int FD, uint64_t Len,
uint64_t Offset, error_code EC)
- : MFR(FD, sys::fs::mapped_file_region::readonly,
+ : MFR(FD, false, sys::fs::mapped_file_region::readonly,
getLegalMapSize(Len, Offset), getLegalMapOffset(Offset), EC) {
if (!EC) {
const char *Start = getStart(Len, Offset);
@@ -281,6 +281,7 @@ error_code MemoryBuffer::getFile(const char *Filename,
error_code ret = getOpenFile(FD, Filename, result, FileSize, FileSize,
0, RequiresNullTerminator);
+ close(FD);
return ret;
}