]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable/table: release filter on error path
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sun, 5 Jul 2026 08:24:27 +0000 (08:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 5 Jul 2026 16:12:10 +0000 (09:12 -0700)
`reftable_table_refs_for_unindexed()` allocates a filtering_ref_iterator
and then calls `reftable_buf_add()` to populate its oid buffer. On
success ownership is transferred to the output iterator, but if
`reftable_buf_add()` fails, the goto-out cleanup only frees the table
iterator and walks away from both the filter allocation and the oid
buffer that `reftable_buf_add()` may have grown.

Release filter->oid and free filter alongside the existing table
iterator cleanup.

Reported by Coverity as CID 1671512 ("Resource leak").

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/table.c

index 56362df0eda5a6b63fbbac5395c97ce05b822596..d604ddebf44dda16f346177ae9e9fedef82e7a3d 100644 (file)
@@ -709,6 +709,10 @@ out:
                if (ti)
                        table_iter_close(ti);
                reftable_free(ti);
+               if (filter) {
+                       reftable_buf_release(&filter->oid);
+                       reftable_free(filter);
+               }
        }
        return err;
 }