diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -327,7 +327,7 @@ PrologueOffset, TotalLength); } FormParams.Version = DebugLineData.getU16(OffsetPtr); - if (getVersion() < 2) + if (getVersion() < 2 || getVersion() > 5) // Treat this error as unrecoverable - we cannot be sure what any of // the data represents including the length field, so cannot skip it or make // any reasonable assumptions. diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -354,6 +354,21 @@ "0x01"); } +TEST_F(DebugLineBasicFixture, ErrorForHighVersion) { + if (!setupGenerator()) + return; + + LineTable < = Gen->addLineTable(); + LT.setCustomPrologue( + {{LineTable::Half, LineTable::Long}, {6, LineTable::Half}}); + + generate(); + + checkGetOrParseLineTableEmitsFatalError( + "parsing line table prologue at offset 0x00000000 found unsupported " + "version 0x06"); +} + TEST_F(DebugLineBasicFixture, ErrorForInvalidV5IncludeDirTable) { if (!setupGenerator(5)) return;