MemoryBuffer: Add a missing error-check to getOpenFileImpl
authorPavel Labath <pavel@labath.sk>
Thu, 15 Aug 2019 08:20:15 +0000 (08:20 +0000)
committerPavel Labath <pavel@labath.sk>
Thu, 15 Aug 2019 08:20:15 +0000 (08:20 +0000)
commit46bfdb956cb805d16388c142ee2872b20896e33b
treed256647d719a9e0a57e65e94808a62d4f5f094e2
parent90374f7557211992bbfb0ba51ad31ee49943f0d3
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
llvm/lib/Support/MemoryBuffer.cpp
llvm/unittests/Support/MemoryBufferTest.cpp