summaryrefslogtreecommitdiff
path: root/src/pkg/go/scanner/scanner.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/go/scanner/scanner.go')
-rw-r--r--src/pkg/go/scanner/scanner.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pkg/go/scanner/scanner.go b/src/pkg/go/scanner/scanner.go
index 7a21205a9..b2e120179 100644
--- a/src/pkg/go/scanner/scanner.go
+++ b/src/pkg/go/scanner/scanner.go
@@ -48,12 +48,17 @@ func (S *Scanner) next() {
S.pos.Column++
r, w := int(S.src[S.offset]), 1
switch {
+ case r == 0:
+ S.error(S.pos, "illegal character NUL")
case r == '\n':
S.pos.Line++
S.pos.Column = 0
case r >= 0x80:
// not ASCII
r, w = utf8.DecodeRune(S.src[S.offset:])
+ if r == utf8.RuneError && w == 1 {
+ S.error(S.pos, "illegal UTF-8 encoding")
+ }
}
S.offset += w
S.ch = r