Commit 8f98def6 by Ian Lance Taylor

compiler: Check for invalid UTF8 in Go comments.

    
    Fixes golang/go#11527.
    
    Reviewed-on: https://go-review.googlesource.com/13905

From-SVN: r227332
parent babb13f5
3aa2ea272e475010da8b480fc3095d0cd7254d12 65672c16004c6d6d0247b6691881d282ffca89e3
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -1689,6 +1689,16 @@ Lex::skip_cpp_comment() ...@@ -1689,6 +1689,16 @@ Lex::skip_cpp_comment()
&& memcmp(p, "line ", 5) == 0) && memcmp(p, "line ", 5) == 0)
{ {
p += 5; 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 == ' ') while (p < pend && *p == ' ')
++p; ++p;
const char* pcolon = static_cast<const char*>(memchr(p, ':', pend - p)); const char* pcolon = static_cast<const char*>(memchr(p, ':', pend - p));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment