Skip to content

Commit 3f3ed7f

Browse files
authored
[DWARF] Fix segfault with empty dwarf .debug_loc (#7910)
An iterator was used when the list was empty.
1 parent 7976b34 commit 3f3ed7f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

third_party/llvm-project/dwarf2yaml.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ void dumpDebugRanges(DWARFContext &DCtx, DWARFYAML::Data &Y) { // XXX BINARYEN
118118
void dumpDebugLoc(DWARFContext &DCtx, DWARFYAML::Data &Y) { // XXX BINARYEN
119119
// This blindly grabs the first CU, which should be ok since they all have
120120
// the same address size?
121-
auto CU = DCtx.normal_units().begin()->get();
121+
auto CUS = DCtx.normal_units();
122+
if (CUS.empty()) {
123+
return;
124+
}
125+
auto CU = CUS.begin()->get();
122126
uint8_t savedAddressByteSize = CU->getFormParams().AddrSize; // XXX BINARYEN
123127
DWARFDataExtractor locsData(DCtx.getDWARFObj(), DCtx.getDWARFObj().getLocSection(),
124128
DCtx.isLittleEndian(), savedAddressByteSize);

0 commit comments

Comments
 (0)