Skip to content

Commit 65672c1

Browse files
Chris Manghaneianlancetaylor
Chris Manghane
authored andcommitted
compiler: Check for invalid UTF8 in Go comments.
Fixes golang/go#11527. Change-Id: I94fd08ae67393c3422858bc6d1d1311d590c842f Reviewed-on: https://go-review.googlesource.com/13905 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 3aa2ea2 commit 65672c1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

go/lex.cc

+10
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,16 @@ Lex::skip_cpp_comment()
16891689
&& memcmp(p, "line ", 5) == 0)
16901690
{
16911691
p += 5;
1692+
1693+
// Before finding FILE:LINENO, make sure line has valid characters.
1694+
const char* pcheck = p;
1695+
while (pcheck < pend)
1696+
{
1697+
unsigned int c;
1698+
bool issued_error;
1699+
pcheck = this->advance_one_utf8_char(pcheck, &c, &issued_error);
1700+
}
1701+
16921702
while (p < pend && *p == ' ')
16931703
++p;
16941704
const char* pcolon = static_cast<const char*>(memchr(p, ':', pend - p));

0 commit comments

Comments
 (0)