]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs/reftable: fix leak when copying reflog fails
authorPatrick Steinhardt <ps@pks.im>
Thu, 8 Feb 2024 05:26:14 +0000 (06:26 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2024 05:30:43 +0000 (21:30 -0800)
When copying a ref with the reftable backend we also copy the
corresponding log records. When seeking the first log record that we're
about to copy fails though we directly return from `write_copy_table()`
without doing any cleanup, leaking several allocated data structures.

Fix this by exiting via our common cleanup logic instead.

Reported-by: Jeff King <peff@peff.net> via Coverity
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/reftable-backend.c

index 85214baa60e66babecc63c08495e61747cc57d85..a14f2ad7f4545230887b433dd72712b30a38fd40 100644 (file)
@@ -1503,7 +1503,7 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data)
         */
        ret = reftable_merged_table_seek_log(mt, &it, arg->oldname);
        if (ret < 0)
-               return ret;
+               goto done;
 
        while (1) {
                ret = reftable_iterator_next_log(&it, &old_log);