[lld] r273398 - [ELF] - Do not crash on unclosed quote (") in scripts.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 04:39:17 PDT 2016


Author: grimar
Date: Wed Jun 22 06:39:16 2016
New Revision: 273398

URL: http://llvm.org/viewvc/llvm-project?rev=273398&view=rev
Log:
[ELF] - Do not crash on unclosed quote (") in scripts.

Found that during investigation of FreeBsd scripts.
Unclosed quote just crashed lld.

Modified:
    lld/trunk/ELF/ScriptParser.cpp
    lld/trunk/test/ELF/version-script-err.s

Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=273398&r1=273397&r2=273398&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Wed Jun 22 06:39:16 2016
@@ -43,7 +43,7 @@ void ScriptParserBase::printErrorPos() {
 void ScriptParserBase::setError(const Twine &Msg) {
   if (Error)
     return;
-  if (Input.empty()) {
+  if (Input.empty() || Tokens.empty()) {
     error(Msg);
   } else {
     error("line " + Twine(getPos()) + ": " + Msg);

Modified: lld/trunk/test/ELF/version-script-err.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script-err.s?rev=273398&r1=273397&r2=273398&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script-err.s (original)
+++ lld/trunk/test/ELF/version-script-err.s Wed Jun 22 06:39:16 2016
@@ -3,3 +3,8 @@
 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
 // RUN: not ld.lld -shared %t.o -o %t.so --version-script %p/Inputs/version-script-err.script 2>&1 | FileCheck %s
 // CHECK: ; expected, but got }
+
+// RUN: echo    "\"" > %terr1.script
+// RUN: not ld.lld --version-script %terr1.script -shared %t.o -o %t.so 2>&1 | \
+// RUN:   FileCheck -check-prefix=ERR1 %s
+// ERR1: unclosed quote
\ No newline at end of file




More information about the llvm-commits mailing list