Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lexer.errInvalidToken panic #184

Merged
merged 2 commits into from
Jul 30, 2018

Conversation

alexej-v
Copy link
Contributor

Fixes panic during processing jlexer.Data with the same length and capacity

@alexej-v alexej-v force-pushed the errInvalidToken_panic_fix branch 2 times, most recently from 78c5fe0 to f8c45dd Compare July 26, 2018 11:10
Copy link
Contributor

@vstarodub vstarodub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, except some minor comments.

jlexer/lexer.go Outdated
isValid, hasEscapes, length := findStringLen(data)
if !isValid {
r.pos += length
r.errParse("missing trailing string literal")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"unterminated string literal", or "missing trailing quote char". A literal is the whole string with opening/ending quote chars.

for _, test := range []struct {
data []byte
}{
{data: []byte(`"sting without trailing literal`)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, "... trailing quote"

l := Lexer{Data: test.data}
l.fetchString()
if l.pos > len(l.Data) {
t.Errorf("pos should not be greater than length of Data")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indicate what test case failed, e.g.:

t.Errorf("fetchString(%s): pos should not be greater than length of Data", test.data)

Same goes for the error below.

@rvasily rvasily merged commit 03f2033 into mailru:master Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants