@@ -584,7 +584,8 @@ DWARFDie DIEBuilder::resolveDIEReference(
584584 if ((RefCU =
585585 getUnitForOffset (*this , *DwarfContext, TmpRefOffset, AttrSpec))) {
586586 // / Trying to add to current working set in case it's cross CU reference.
587- registerUnit (*RefCU, true );
587+ if (!registerUnit (*RefCU, true ))
588+ return DWARFDie ();
588589 DWARFDataExtractor DebugInfoData = RefCU->getDebugInfoExtractor ();
589590 if (DwarfDebugInfoEntry.extractFast (*RefCU, &TmpRefOffset, DebugInfoData,
590591 RefCU->getNextUnitOffset (), 0 )) {
@@ -1008,12 +1009,14 @@ static uint64_t getHash(const DWARFUnit &DU) {
10081009 return DU.getOffset ();
10091010}
10101011
1011- void DIEBuilder::registerUnit (DWARFUnit &DU, bool NeedSort) {
1012+ bool DIEBuilder::registerUnit (DWARFUnit &DU, bool NeedSort) {
1013+ if (!BC.isValidDwarfUnit (DU))
1014+ return false ;
10121015 auto IterGlobal = AllProcessed.insert (getHash (DU));
10131016 // If DU is already in a current working set or was already processed we can
10141017 // skip it.
10151018 if (!IterGlobal.second )
1016- return ;
1019+ return true ;
10171020 if (getState ().Type == ProcessingType::DWARF4TUs) {
10181021 getState ().DWARF4TUVector .push_back (&DU);
10191022 } else if (getState ().Type == ProcessingType::DWARF5TUs) {
@@ -1034,6 +1037,7 @@ void DIEBuilder::registerUnit(DWARFUnit &DU, bool NeedSort) {
10341037 if (getState ().DUList .size () == getState ().CloneUnitCtxMap .size ())
10351038 getState ().CloneUnitCtxMap .emplace_back ();
10361039 getState ().DUList .push_back (&DU);
1040+ return true ;
10371041}
10381042
10391043std::optional<uint32_t > DIEBuilder::getUnitId (const DWARFUnit &DU) {
0 commit comments