mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-18 21:24:32 -04:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368977 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user