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

[PATCH] unpack-trees: release oid_array after use in check_updates()

From
René Scharfe <l.s.r@web.de>
Date
Mar 25, 2018, 16:31 UTC
Message-ID
<b2380d1e-1d45-22cf-ba22-cf4cb02e1134@web.de>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
That leak was introduced by c0c578b33c (unpack-trees: batch fetching of
missing blobs).
 unpack-trees.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/unpack-trees.c b/unpack-trees.c
index d5685891a5..e73745051e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -379,30 +379,31 @@ static int check_updates(struct unpack_trees_options *o)
 		struct oid_array to_fetch = OID_ARRAY_INIT;
 		int fetch_if_missing_store = fetch_if_missing;
 		fetch_if_missing = 0;
 		for (i = 0; i < index->cache_nr; i++) {
 			struct cache_entry *ce = index->cache[i];
 			if ((ce->ce_flags & CE_UPDATE) &&
 			    !S_ISGITLINK(ce->ce_mode)) {
 				if (!has_object_file(&ce->oid))
 					oid_array_append(&to_fetch, &ce->oid);
 			}
 		}
 		if (to_fetch.nr)
 			fetch_objects(repository_format_partial_clone,
 				      &to_fetch);
 		fetch_if_missing = fetch_if_missing_store;
+		oid_array_clear(&to_fetch);
 	}
 	for (i = 0; i < index->cache_nr; i++) {
 		struct cache_entry *ce = index->cache[i];
 
 		if (ce->ce_flags & CE_UPDATE) {
 			if (ce->ce_flags & CE_WT_REMOVE)
 				die("BUG: both update and delete flags are set on %s",
 				    ce->name);
 			display_progress(progress, ++cnt);
 			ce->ce_flags &= ~CE_UPDATE;
 			if (o->update && !o->dry_run) {
 				errs |= checkout_entry(ce, &state, NULL);
 			}
 		}
 	}
-- 
2.16.3
Next: Derrick Stolee
Message 1 of 2 in “unpack-trees: release oid_array after use in check_updates()”
  1. unpack-trees: release oid_array after use in check_updates()René Scharfe, Mar 25, 2018
  2. Derrick StoleeMar 25, 2018

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.