diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-03-14 00:20:10 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-03-14 00:20:10 +0000 |
commit | cc3a595ab938352f3acf8652c5858ddf879524a5 (patch) | |
tree | 1f67c816387fd6a44ecf54063cc9c283b06642a3 /lib/Support/MemoryBuffer.cpp | |
parent | 64a0a33307723957bf2f15e3181a290853c6f833 (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.cpp | 3 |
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; } |