{"thread":{"id":"60872","subject":"[PATCH] refs/reftable: fix leak when copying reflog fails","startedAt":"2024-02-08T05:26:19Z","lastAt":"2024-02-15T05:32:06Z","messageCount":2,"participants":["Patrick Steinhardt","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"488207","messageId":"02f7a97a451927f9a7ee06f3c5ea5af4c4eb6645.1707369907.git.ps@pks.im","threadId":"60872","inReplyTo":null,"subject":"[PATCH] refs/reftable: fix leak when copying reflog fails","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-08T05:26:14Z","receivedAt":"2024-02-08T05:26:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When copying a ref with the reftable backend we also copy the\ncorresponding log records. When seeking the first log record that we're\nabout to copy fails though we directly return from `write_copy_table()`\nwithout doing any cleanup, leaking several allocated data structures.\n\nFix this by exiting via our common cleanup logic instead.\n\nReported-by: Jeff King <peff@peff.net> via Coverity\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n refs/reftable-backend.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/refs/reftable-backend.c b/refs/reftable-backend.c\nindex 85214baa60..a14f2ad7f4 100644\n--- a/refs/reftable-backend.c\n+++ b/refs/reftable-backend.c\n@@ -1503,7 +1503,7 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data)\n \t */\n \tret = reftable_merged_table_seek_log(mt, &it, arg->oldname);\n \tif (ret < 0)\n-\t\treturn ret;\n+\t\tgoto done;\n \n \twhile (1) {\n \t\tret = reftable_iterator_next_log(&it, &old_log);\n-- \n2.43.GIT\n\n"},{"id":"488683","messageId":"20240215053205.GE2821179@coredump.intra.peff.net","threadId":"60872","inReplyTo":"02f7a97a451927f9a7ee06f3c5ea5af4c4eb6645.1707369907.git.ps@pks.im","subject":"Re: [PATCH] refs/reftable: fix leak when copying reflog fails","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-02-15T05:32:05Z","receivedAt":"2024-02-15T05:32:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 08, 2024 at 06:26:14AM +0100, Patrick Steinhardt wrote:\n\n> When copying a ref with the reftable backend we also copy the\n> corresponding log records. When seeking the first log record that we're\n> about to copy fails though we directly return from `write_copy_table()`\n> without doing any cleanup, leaking several allocated data structures.\n> \n> Fix this by exiting via our common cleanup logic instead.\n\nThanks, this looks obviously correct to me. :)\n\n-Peff\n"}]}