git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] refs/reftable: fix leak when copying reflog fails

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 8, 2024, 05:26 UTC
Message-ID
<02f7a97a451927f9a7ee06f3c5ea5af4c4eb6645.1707369907.git.ps@pks.im>

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>
---
 refs/reftable-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
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);
-- 
2.43.GIT
Next: Jeff King
Message 1 of 2 in “refs/reftable: fix leak when copying reflog fails”
  1. refs/reftable: fix leak when copying reflog failsPatrick Steinhardt, Feb 8, 2024
  2. Jeff KingFeb 15, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.