diff options
author | Bob Haarman <llvm@inglorion.net> | 2016-12-05 22:44:00 +0000 |
---|---|---|
committer | Bob Haarman <llvm@inglorion.net> | 2016-12-05 22:44:00 +0000 |
commit | a5b4358956135e2aa747d7dfca4d361ebf99e99d (patch) | |
tree | 4d8f6b707d36857f15be8163b17fc5a7e80e24e5 /llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp | |
parent | 317dcc3f2f37c95619a4db9c6d4c084983fdf7ba (diff) | |
download | bcm5719-llvm-a5b4358956135e2aa747d7dfca4d361ebf99e99d.tar.gz bcm5719-llvm-a5b4358956135e2aa747d7dfca4d361ebf99e99d.zip |
[pdb] handle missing pdb streams more gracefully
Summary: The code we use to read PDBs assumed that streams we ask it to read exist, and would read memory outside a vector and crash if this wasn't the case. This would, for example, cause llvm-pdbdump to crash on PDBs generated by lld. This patch handles such cases more gracefully: the PDB reading code in LLVM now reports errors when asked to get a stream that is not present, and llvm-pdbdump will report missing streams and continue processing streams that are present.
Reviewers: ruiu, zturner
Subscribers: thakis, amccarth
Differential Revision: https://reviews.llvm.org/D27325
llvm-svn: 288722
Diffstat (limited to 'llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp b/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp index 403c02b4268..e52c88a5bfb 100644 --- a/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp +++ b/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp @@ -63,6 +63,7 @@ std::unique_ptr<MappedBlockStream> MappedBlockStream::createIndexedStream(const MSFLayout &Layout, const ReadableStream &MsfData, uint32_t StreamIndex) { + assert(StreamIndex < Layout.StreamMap.size() && "Invalid stream index"); MSFStreamLayout SL; SL.Blocks = Layout.StreamMap[StreamIndex]; SL.Length = Layout.StreamSizes[StreamIndex]; @@ -334,6 +335,7 @@ std::unique_ptr<WritableMappedBlockStream> WritableMappedBlockStream::createIndexedStream(const MSFLayout &Layout, const WritableStream &MsfData, uint32_t StreamIndex) { + assert(StreamIndex < Layout.StreamMap.size() && "Invalid stream index"); MSFStreamLayout SL; SL.Blocks = Layout.StreamMap[StreamIndex]; SL.Length = Layout.StreamSizes[StreamIndex]; |