Skip to content

Commit

Permalink
compiler: Check for invalid UTF8 in Go comments.
Browse files Browse the repository at this point in the history
Fixes golang/go#11527.

Change-Id: I94fd08ae67393c3422858bc6d1d1311d590c842f
Reviewed-on: https://go-review.googlesource.com/13905
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Aug 31, 2015
1 parent 3aa2ea2 commit 65672c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions go/lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 65672c1

Please sign in to comment.