summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-08-15 08:20:15 +0000
committerPavel Labath <pavel@labath.sk>2019-08-15 08:20:15 +0000
commit46bfdb956cb805d16388c142ee2872b20896e33b (patch)
treed256647d719a9e0a57e65e94808a62d4f5f094e2 /llvm/lib/Support
parent90374f7557211992bbfb0ba51ad31ee49943f0d3 (diff)
downloadbcm5719-llvm-46bfdb956cb805d16388c142ee2872b20896e33b.tar.gz
bcm5719-llvm-46bfdb956cb805d16388c142ee2872b20896e33b.zip
MemoryBuffer: Add a missing error-check to getOpenFileImpl
Summary: 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: 368977
Diffstat (limited to 'llvm/lib/Support')
-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