Skip to content

Commit 31a577d

Browse files
committed
notes: check error code returned by git_iterator_advance
When calling `git_note_next`, we end up calling `git_iterator_advance` but ignore its error code. The intent is that we do not want to return an error if it returns `GIT_ITEROVER`, as we want to return that value on the next invocation of `git_note_next`. We should still check for any other error codes returned by `git_iterator_advance` to catch unexpected internal errors. Fix this by checking the function's return value, ignoring `GIT_ITEROVER`.
1 parent 2e6cbff commit 31a577d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/notes.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,11 @@ int git_note_next(
808808

809809
git_oid_cpy(note_id, &item->id);
810810

811-
if (!(error = process_entry_path(item->path, annotated_id)))
812-
git_iterator_advance(NULL, it);
811+
if ((error = process_entry_path(item->path, annotated_id)) < 0)
812+
return error;
813813

814-
return error;
814+
if ((error = git_iterator_advance(NULL, it)) < 0 && error != GIT_ITEROVER)
815+
return error;
816+
817+
return 0;
815818
}

0 commit comments

Comments
 (0)