git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Jonathan Tan <jonathantanmy@google.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] unpack-trees: release oid_array after use in check_updates()
Date: Sun, 25 Mar 2018 18:31:48 +0200	[thread overview]
Message-ID: <b2380d1e-1d45-22cf-ba22-cf4cb02e1134@web.de> (raw)

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

             reply	other threads:[~2018-03-25 16:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-25 16:31 René Scharfe [this message]
2018-03-25 18:33 ` [PATCH] unpack-trees: release oid_array after use in check_updates() Derrick Stolee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2380d1e-1d45-22cf-ba22-cf4cb02e1134@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).