compiler: Check for invalid UTF8 in Go comments.
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 31 Aug 2015 01:58:48 +0000 (01:58 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 31 Aug 2015 01:58:48 +0000 (01:58 +0000)
    Fixes golang/go#11527.

    Reviewed-on: https://go-review.googlesource.com/13905

From-SVN: r227332

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/lex.cc

index beb095a5557a0777de916ee4cda575a5c5b320b5..87ef51844f766ebd69523aadf486e519bb60581b 100644 (file)
@@ -1,4 +1,4 @@
-3aa2ea272e475010da8b480fc3095d0cd7254d12
+65672c16004c6d6d0247b6691881d282ffca89e3
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 632a1c9e353ced3ee94255e76a1ce2fda7569cb3..67f780342660755a8bb1016e2af5016620f810dd 100644 (file)
@@ -1689,6 +1689,16 @@ Lex::skip_cpp_comment()
       && memcmp(p, "line ", 5) == 0)
     {
       p += 5;
+
+      // Before finding FILE:LINENO, make sure line has valid characters.
+      const char* pcheck = p;
+      while (pcheck < pend)
+        {
+          unsigned int c;
+          bool issued_error;
+          pcheck = this->advance_one_utf8_char(pcheck, &c, &issued_error);
+        }
+
       while (p < pend && *p == ' ')
        ++p;
       const char* pcolon = static_cast<const char*>(memchr(p, ':', pend - p));