[pdb] Fix size check when reading stream bytes.

We were accidentally bounds checking the read against the output
ArrayRef instead of against the size of the read.

llvm-svn: 271040
This commit is contained in:
Zachary Turner 2016-05-27 20:17:33 +00:00
parent 6481a0f020
commit 7dd42598be
1 changed files with 2 additions and 2 deletions

View File

@ -26,9 +26,9 @@ MappedBlockStream::MappedBlockStream(uint32_t StreamIdx, const PDBFile &File) :
Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size,
ArrayRef<uint8_t> &Buffer) const {
// Make sure we aren't trying to read beyond the end of the stream.
if (Buffer.size() > StreamLength)
if (Size > StreamLength)
return make_error<RawError>(raw_error_code::insufficient_buffer);
if (Offset > StreamLength - Buffer.size())
if (Offset > StreamLength - Size)
return make_error<RawError>(raw_error_code::insufficient_buffer);
if (tryReadContiguously(Offset, Size, Buffer))