From c6cb2ec36ea5a3c149b58a3bb28dccafaa8ceaa0 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 28 May 2016 20:04:46 +0000 Subject: [SymbolDumper] Validate the string table offset before using it llvm-svn: 271145 --- llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'llvm/lib/DebugInfo/CodeView') diff --git a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp index 4afcdf189f2..3ce84ac1a76 100644 --- a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -591,12 +591,12 @@ void CVSymbolDumperImpl::visitDefRangeSubfieldSym( if (ObjDelegate) { StringRef StringTable = ObjDelegate->getStringTable(); - if (!StringTable.empty()) { - W.printString("Program", - StringTable.drop_front(DefRangeSubfield.Header.Program) - .split('\0') - .first); - } + auto ProgramStringTableOffset = DefRangeSubfield.Header.Program; + if (ProgramStringTableOffset >= StringTable.size()) + return parseError(); + StringRef Program = + StringTable.drop_front(ProgramStringTableOffset).split('\0').first; + W.printString("Program", Program); } W.printNumber("OffsetInParent", DefRangeSubfield.Header.OffsetInParent); printLocalVariableAddrRange(DefRangeSubfield.Header.Range, -- cgit v1.2.3