diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 014279b5f0a7d9..612a06d8cc72c3 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1508,11 +1508,12 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( DINode::DIFlags Flags = (Record.size() > 6) ? static_cast(Record[6]) : DINode::FlagZero; + uint32_t NumExtraInhabitants = (Record.size() > 7) ? Record[7] : 0; MetadataList.assignValue( GET_OR_DISTINCT(DIBasicType, (Context, Record[1], getMDString(Record[2]), Record[3], - Record[4], Record[5], Record[7], Flags)), + Record[4], Record[5], NumExtraInhabitants, Flags)), NextMetadataNo); NextMetadataNo++; break; @@ -1588,7 +1589,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( return error("Alignment value is too large"); uint32_t AlignInBits = Record[8]; uint64_t OffsetInBits = 0; - uint32_t NumExtraInhabitants = Record[22]; + uint32_t NumExtraInhabitants = (Record.size() > 22) ? Record[22] : 0; DINode::DIFlags Flags = static_cast(Record[10]); Metadata *Elements = nullptr; unsigned RuntimeLang = Record[12];