t/unit-tests: check reftable iterator initialization

Coverity pointed out that the
`test_reftable_table__seek_invalid_log_offset()` test, which was
introduced by a1c085df8d (reftable/table: fix NULL pointer access when
seeking to bogus offsets, 2026-07-03), ignores the result of
`reftable_table_init_log_iterator()` and proceeds to
`reftable_iterator_seek_log()`, although initialization can return
`REFTABLE_OUT_OF_MEMORY_ERROR` without installing an ops table. Under
allocation failure, the test then dereferences a NULL function table.

Assert successful iterator initialization before seeking.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
jch
Johannes Schindelin 2026-09-17 17:52:34 +00:00 committed by Junio C Hamano
parent 742d8eb897
commit 11ab0ca4e3
1 changed files with 1 additions and 1 deletions

View File

@ -257,7 +257,7 @@ void test_reftable_table__seek_invalid_log_offset(void)
* know that the table is corrupt, so the seek must report a format
* error instead of pretending that the section is empty.
*/
reftable_table_init_log_iterator(table, &it);
cl_assert_equal_i(reftable_table_init_log_iterator(table, &it), 0);
cl_assert_equal_i(reftable_iterator_seek_log(&it, ""),
REFTABLE_FORMAT_ERROR);