Skip to content

Commit

Permalink
go/scanner: recognize invalid floating-point constant exponent
Browse files Browse the repository at this point in the history
Fixes #17621.

Change-Id: Id3e75c9b7fba2cf8e791c8817f890556ca238e9d
Reviewed-on: https://go-review.googlesource.com/32096
Reviewed-by: Josh Bleecher Snyder <[email protected]>
  • Loading branch information
griesemer committed Oct 26, 2016
1 parent 4b26657 commit 3cfc757
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/go/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ exponent:
if s.ch == '-' || s.ch == '+' {
s.next()
}
s.scanMantissa(10)
if digitVal(s.ch) < 10 {
s.scanMantissa(10)
} else {
s.error(offs, "illegal floating-point exponent")
}
}

if s.ch == 'i' {
Expand Down
1 change: 1 addition & 0 deletions src/go/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ var errors = []struct {
{"078.", token.FLOAT, 0, "078.", ""},
{"07801234567.", token.FLOAT, 0, "07801234567.", ""},
{"078e0", token.FLOAT, 0, "078e0", ""},
{"0E", token.FLOAT, 0, "0E", "illegal floating-point exponent"}, // issue 17621
{"078", token.INT, 0, "078", "illegal octal number"},
{"07800000009", token.INT, 0, "07800000009", "illegal octal number"},
{"0x", token.INT, 0, "0x", "illegal hexadecimal number"},
Expand Down

0 comments on commit 3cfc757

Please sign in to comment.