Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ std::optional<CVType> LazyRandomTypeCollection::tryGetType(TypeIndex Index) {
return std::nullopt;
}

assert(contains(Index));
if (!contains(Index))
return std::nullopt;
return Records[Index.toArrayIndex()].Type;
}

Expand Down
13 changes: 13 additions & 0 deletions llvm/test/DebugInfo/PDB/Native/pdb-native-index-overflow.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; Test that the native PDB reader isn't crashed by index value bigger than
; number of types in TPI or IPI stream
; RUN: llvm-pdbutil dump %p/../Inputs/empty.pdb --type-index=20000000\
; RUN: | FileCheck -check-prefixes=TYPES,NOT_FOUND %s
; RUN: llvm-pdbutil dump %p/../Inputs/empty.pdb --id-index=20000000\
; RUN: | FileCheck -check-prefixes=IDS,NOT_FOUND %s

TYPES: Types (TPI Stream)
IDS: Types (IPI Stream)
NOT_FOUND:============================================================
NOT_FOUND: Showing 1 records.
NOT_FOUND: Type 0x1312D00 doesn't exist in TPI stream