[llvm] r271040 - [pdb] Fix size check when reading stream bytes.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 13:17:36 PDT 2016


Author: zturner
Date: Fri May 27 15:17:33 2016
New Revision: 271040

URL: http://llvm.org/viewvc/llvm-project?rev=271040&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp?rev=271040&r1=271039&r2=271040&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp Fri May 27 15:17:33 2016
@@ -26,9 +26,9 @@ MappedBlockStream::MappedBlockStream(uin
 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))




More information about the llvm-commits mailing list