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

[PATCH] builtin-update-index.c (add_file_to_cache): Don't leak a cache entry.

From
Jim Meyering <jim@meyering.net>
Date
Feb 16, 2007, 09:01 UTC
Message-ID
<87mz3e327y.fsf@rho.meyering.net>
Signed-off-by: Jim Meyering <jim@meyering.net>
---
 builtin-update-index.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 1ac613a..5b2278e 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -121,8 +121,10 @@ static int add_file_to_cache(const char *path)
 			ce->ce_mode = create_ce_mode(S_IFREG | 0666);
 	}

-	if (index_path(ce->sha1, path, &st, !info_only))
+	if (index_path(ce->sha1, path, &st, !info_only)) {
+		free(ce);
 		return -1;
+	}
 	option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
 	option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
 	if (add_cache_entry(ce, option))
--
1.5.0.33.gaf997-dirty
Next: Linus Torvalds
Message 1 of 3 in “builtin-update-index.c (add_file_to_cache): Don't leak a cache entry.”
  1. builtin-update-index.c (add_file_to_cache): Don't leak a cache entry.Jim Meyering, Feb 16, 2007
  2. Linus TorvaldsFeb 16, 2007
  3. Jim MeyeringFeb 18, 2007

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.