[llvm-pdbdump] Try to appease the ASan bot

We didn't check that the file was large enough to hold a super block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267965 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2016-04-29 01:00:17 +00:00
parent 5f1ec2bfa8
commit 7fdc84bb3c

View File

@ -122,6 +122,11 @@ std::error_code PDBFile::parseFileHeaders() {
Context->SB =
reinterpret_cast<const SuperBlock *>(BufferRef.getBufferStart());
const SuperBlock *SB = Context->SB;
// Make sure the file is sufficiently large to hold a super block.
if (BufferRef.getBufferSize() < sizeof(SuperBlock))
return std::make_error_code(std::errc::illegal_byte_sequence);
// Check the magic bytes.
if (memcmp(SB->MagicBytes, Magic, sizeof(Magic)) != 0)
return std::make_error_code(std::errc::illegal_byte_sequence);