From 86611a078f1d9d16caf1951b22763fa322dcce73 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Tue, 25 Apr 2017 18:56:33 +0000 Subject: [PATCH] [llvm-objdump] Don't attempt to print lines beyond the end of file This may trigger a segfault in llvm-objdump when the line number stored in debug infromation points beyond the end of file; lines in LineBuffer are stored in std::vector which is allocated in chunks, so even if the debug info points beyond the end of the file, this doesn't necessarily trigger the segfault unless the line number points beyond the allocated space. Differential Revision: https://reviews.llvm.org/D32466 llvm-svn: 301347 --- .../X86/Inputs/debug-info-fileinfo.exe.elf-x86_64 | Bin 0 -> 1540 bytes .../llvm-objdump/X86/debug-info-fileinfo.test | 27 +++++++++++++++++++++ llvm/tools/llvm-objdump/llvm-objdump.cpp | 5 +++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 llvm/test/tools/llvm-objdump/X86/Inputs/debug-info-fileinfo.exe.elf-x86_64 create mode 100644 llvm/test/tools/llvm-objdump/X86/debug-info-fileinfo.test diff --git a/llvm/test/tools/llvm-objdump/X86/Inputs/debug-info-fileinfo.exe.elf-x86_64 b/llvm/test/tools/llvm-objdump/X86/Inputs/debug-info-fileinfo.exe.elf-x86_64 new file mode 100644 index 0000000000000000000000000000000000000000..2074886c66560330e57707ffc307a485042836b1 GIT binary patch literal 1540 zcmbtU&2G~`5T3P5aEXn)L zESrpC)d|W)EEvnU!cCSQcgxW@{&esZls25uf)809?nkYt6*fds<|pBk*52c1d%Iyn zPqO6pcY&OGTqK21RjcCP*gpUtydGn!8aI%i*(&+~q((OH*2os|gPq_(a2u=bT}SY| z@}g2B4^i%K%UX@`^WZ)9g#5jA6MMC-SSg|l18`+!aL|=8S?UcBs-9i!wqFhFb&p^M zi1=(Ik`%2dv>jMa(5Zk(P1{KdtS#jh%Du6ElBNZnSd LineBuffer->second.size()) + return; // Vector begins at 0, line numbers are non-zero OS << Delimiter << LineBuffer->second[LineInfo.Line - 1].ltrim() << "\n"; + } } } OldLineInfo = LineInfo; -- 2.7.4