File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ func (p *parsing) checkPoint() bool {
150150
151151// parse bytes (p.str) to tokens and append them to the end if stream of tokens.
152152func (p * parsing ) parse () {
153- if len (p .str ) == 0 {
153+ if len (p .str ) == p . pos {
154154 if p .reader == nil || p .loadChunk () == 0 { // if it's not an infinite stream, or this is the end of the stream
155155 return
156156 }
Original file line number Diff line number Diff line change @@ -273,6 +273,19 @@ func TestIssue9(t *testing.T) {
273273 }
274274}
275275
276+ // TestIssue26 panic when stream with more than one token ends with any white space
277+ func TestIssue26 (t * testing.T ) {
278+ parser := New ()
279+ buf := bytes .NewBufferString ("test coucou\n " )
280+
281+ stream := parser .ParseStream (buf , 4096 )
282+ defer stream .Close ()
283+ for stream .IsValid () {
284+ // do something...
285+ stream .GoNext () // Should not panic
286+ }
287+ }
288+
276289func TestStreamOverflow (t * testing.T ) {
277290 parser := New ()
278291 buf := bytes .NewBuffer ([]byte ("a b c" ))
You can’t perform that action at this time.
0 commit comments