File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,15 +39,24 @@ func NewListIterator(data RawValue) (*listIterator, error) {
3939
4040}
4141
42- // Next forwards the iterator one step, returns true if it was not at end yet
42+ // Next forwards the iterator one step.
43+ // Returns true if there is a next item or an error occurred on this step (check Err()).
44+ // On parse error, the iterator is marked finished and subsequent calls return false.
4345func (it * listIterator ) Next () bool {
4446 if len (it .data ) == 0 {
4547 return false
4648 }
4749 _ , t , c , err := readKind (it .data )
50+ if err != nil {
51+ it .next = nil
52+ it .err = err
53+ // Mark iteration as finished to avoid potential infinite loops on subsequent Next calls.
54+ it .data = nil
55+ return true
56+ }
4857 it .next = it .data [:t + c ]
4958 it .data = it .data [t + c :]
50- it .err = err
59+ it .err = nil
5160 return true
5261}
5362
You can’t perform that action at this time.
0 commit comments