From b343310b4f500f9274d1c659a3b9cab6ecce6651 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 28 May 2016 19:45:56 +0000 Subject: [PATCH] [SymbolDumper] Validate the string table offset before using it llvm-svn: 271142 --- llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp index e2dc9d5b76d5..4afcdf189f29 100644 --- a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -610,11 +610,12 @@ void CVSymbolDumperImpl::visitDefRangeSym(SymbolKind Kind, if (ObjDelegate) { StringRef StringTable = ObjDelegate->getStringTable(); - if (!StringTable.empty()) { - W.printString( - "Program", - StringTable.drop_front(DefRange.Header.Program).split('\0').first); - } + auto ProgramStringTableOffset = DefRange.Header.Program; + if (ProgramStringTableOffset >= StringTable.size()) + return parseError(); + StringRef Program = + StringTable.drop_front(ProgramStringTableOffset).split('\0').first; + W.printString("Program", Program); } printLocalVariableAddrRange(DefRange.Header.Range, DefRange.getRelocationOffset());