summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/MemoryBuffer.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-08-20 12:08:52 +0000
committerPavel Labath <pavel@labath.sk>2019-08-20 12:08:52 +0000
commit51d7398f630cee2239cf0c624d0fa60c63c7375a (patch)
treeb45724cbf3e9107e3d0b7cbad5bd855ca58e8555 /llvm/lib/Support/MemoryBuffer.cpp
parented72e0ecf80ebe8717e6c3ea316ce359f0c52a43 (diff)
downloadbcm5719-llvm-51d7398f630cee2239cf0c624d0fa60c63c7375a.tar.gz
bcm5719-llvm-51d7398f630cee2239cf0c624d0fa60c63c7375a.zip
Recommit "MemoryBuffer: Add a missing error-check to getOpenFileImpl"
This recommits r368977, which was reverted in r369027 due to test failures in lldb. The cause of this was different behavior of readNativeFileSlice on windows and unix. These have been addressed in r369269. The original commit message was: In case the function was called with a desired read size *and* the file was not an "mmap()" candidate, the function was falling back to a "pread()", but it was failing to check the result of that system call. This meant that the function would return "success" even though the read operation failed, and it returned a buffer full of uninitialized memory. Reviewers: rnk, dblaikie Subscribers: kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66224 llvm-svn: 369370
Diffstat (limited to 'llvm/lib/Support/MemoryBuffer.cpp')
-rw-r--r--llvm/lib/Support/MemoryBuffer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp
index d0e5bb154c1..2f31f059ddb 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -458,7 +458,9 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
return make_error_code(errc::not_enough_memory);
}
- sys::fs::readNativeFileSlice(FD, Buf->getBuffer(), Offset);
+ if (std::error_code EC =
+ sys::fs::readNativeFileSlice(FD, Buf->getBuffer(), Offset))
+ return EC;
return std::move(Buf);
}
OpenPOWER on IntegriCloud