From: Patrick Steinhardt Date: Thu, 8 Feb 2024 05:26:14 +0000 (+0100) Subject: refs/reftable: fix leak when copying reflog fails X-Git-Tag: v2.45.0-rc0~176^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a0bebdeaec60623c8a791b197d574bdd031a452;p=thirdparty%2Fgit.git refs/reftable: fix leak when copying reflog fails 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 via Coverity Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c index 85214baa60..a14f2ad7f4 100644 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@ -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);