Skip to content

Commit

Permalink
fix: check inner quad iterator for errors when closing
Browse files Browse the repository at this point in the history
This caused a bug where Scan returned an error which was ignored by the
iterator. The inner iterator it.Err() would have returned the error correctly,
but it was ignored in QuadIterator.

Fixed by checking the inner iterator error when closing.

Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed May 24, 2023
1 parent b692fb1 commit 0423d8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion graph/kv/quad_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func (it *quadIteratorNext) TagResults(dst map[string]graph.Ref) {}

func (it *quadIteratorNext) Close() error {
if it.it != nil {
if err := it.it.Err(); err != nil && it.err == nil {
it.err = err
}
if err := it.it.Close(); err != nil && it.err == nil {
it.err = err
}
Expand Down Expand Up @@ -179,7 +182,8 @@ func (it *quadIteratorNext) Next(ctx context.Context) bool {
it.ids = nil
it.buf = nil
if !it.it.Next(ctx) {
it.Close()
// note: it.Err() is checked in Close()
_ = it.Close()
it.done = true
return false
}
Expand Down

0 comments on commit 0423d8c

Please sign in to comment.