File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ func (s *Stream) GoTo(id int) *Stream {
166166// IsValid checks if stream is valid.
167167// This means that the pointer has not reached the end of the stream.
168168func (s * Stream ) IsValid () bool {
169- return s .current != undefToken
169+ return s .current != nil && s . current != undefToken
170170}
171171
172172// IsNextSequence checks if these are next tokens in exactly the same sequence as specified.
Original file line number Diff line number Diff line change @@ -272,6 +272,20 @@ func TestIssue9(t *testing.T) {
272272 }
273273}
274274
275+ func TestIssue7 (t * testing.T ) {
276+ p := New ()
277+ buf := bytes .NewBuffer (nil )
278+
279+ stream := p .ParseStream (buf , 4096 )
280+ defer stream .Close ()
281+
282+ for stream .IsValid () {
283+ token := stream .CurrentToken ()
284+ require .False (t , token .Is (TokenInteger ))
285+ stream .GoNext ()
286+ }
287+ }
288+
275289var pattern = []byte (`<item count=10 valid id="n9762"> Носки <![CDATA[ socks ]]></item>` )
276290
277291type dataGenerator struct {
You can’t perform that action at this time.
0 commit comments