-
-
Notifications
You must be signed in to change notification settings - Fork 152
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: unexpected behavior when buffer ends with backslash #383
Conversation
Co-authored-by: Sungyun Hur <ethan0311@gmail.com>
internal/decoder/stream.go
Outdated
@@ -344,6 +345,7 @@ func (s *Stream) skipArray(depth int64) error { | |||
s.cursor = cursor | |||
if s.read() { | |||
_, cursor, p = s.statForRetry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding a new parameter rewindCursor
in statForRetry
? (or make a new function)
func (s *Stream) statForRetry(rewindCursor bool) ([]byte, int64, unsafe.Pointer) {
if rewindCursor {
s.cursor-- // for retry ( because caller may progress cursor position in each loop )
}
return s.buf, s.cursor, (*sliceHeader)(unsafe.Pointer(&s.buf)).data
}
It may confuse when additional cursor increments happens outside of statForRetry
function.
@goccy Could you please review this PR? |
internal/decoder/stream.go
Outdated
@@ -281,6 +281,7 @@ func (s *Stream) skipObject(depth int64) error { | |||
s.cursor = cursor | |||
if s.read() { | |||
_, cursor, p = s.statForRetry() | |||
cursor++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use s.stat()
instead of s.statForRetry()
and remove cursor++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks clearer! I reflected your review in the following commit.
Thank you for the contribution !! LGTM ! |
fix #384
by increasing cursor by 1 to escape character properly.