Skip to content

Commit

Permalink
compiler: Avoid unsafe memcmp for nointerface comments.
Browse files Browse the repository at this point in the history
Fixes golang/go#11577.

Change-Id: Ibdd264eaaaaf82bd7da48da80df139254cc88912
Reviewed-on: https://go-review.googlesource.com/14182
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Sep 11, 2015
1 parent 352617b commit aea4360
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,9 @@ Lex::skip_cpp_comment()
// For field tracking analysis: a //go:nointerface comment means
// that the next interface method should not be stored in the type
// descriptor. This permits it to be discarded if it is not needed.
if (this->lineoff_ == 2 && memcmp(p, "go:nointerface", 14) == 0)
if (this->lineoff_ == 2
&& pend - p > 14
&& memcmp(p, "go:nointerface", 14) == 0)
this->saw_nointerface_ = true;

while (p < pend)
Expand Down

0 comments on commit aea4360

Please sign in to comment.