Skip to content

Commit aea4360

Browse files
Chris Manghaneianlancetaylor
Chris Manghane
authored andcommitted
compiler: Avoid unsafe memcmp for nointerface comments.
Fixes golang/go#11577. Change-Id: Ibdd264eaaaaf82bd7da48da80df139254cc88912 Reviewed-on: https://go-review.googlesource.com/14182 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 352617b commit aea4360

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

go/lex.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,9 @@ Lex::skip_cpp_comment()
17521752
// For field tracking analysis: a //go:nointerface comment means
17531753
// that the next interface method should not be stored in the type
17541754
// descriptor. This permits it to be discarded if it is not needed.
1755-
if (this->lineoff_ == 2 && memcmp(p, "go:nointerface", 14) == 0)
1755+
if (this->lineoff_ == 2
1756+
&& pend - p > 14
1757+
&& memcmp(p, "go:nointerface", 14) == 0)
17561758
this->saw_nointerface_ = true;
17571759

17581760
while (p < pend)

0 commit comments

Comments
 (0)