[llvm-pdbdump] Try to appease the ASan bot
We didn't check that the file was large enough to hold a super block.
llvm-svn: 267965
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
index be1368e..0adabfe 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
@@ -122,6 +122,11 @@
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);