[pdb] Try to fix use after free.
llvm-svn: 272078
diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
index 386f8ac..f34a513 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
@@ -104,6 +104,10 @@
return EC;
// Hash indices, hash values, etc come from the hash stream.
+ if (Header->HashStreamIndex >= Pdb.getNumStreams())
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Invalid TPI hash stream index.");
+
HashStream.reset(new MappedBlockStream(
llvm::make_unique<IndexedStreamData>(Header->HashStreamIndex, Pdb), Pdb));
codeview::StreamReader HSR(*HashStream);