git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] ref-filter: plug memory leak in reach_filter()
@ 2020-09-26  8:37 René Scharfe
  2020-09-26 14:53 ` Aaron Lipman
  0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2020-09-26  8:37 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Aaron Lipman

21bf933928 (ref-filter: allow merged and no-merged filters, 2020-09-15)
added an early return to reach_filter().  Avoid leaking the memory of a
then unused array by postponing its allocation until we know we need it.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 ref-filter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ref-filter.c b/ref-filter.c
index 5550a0d34c..e0b8cd3ed8 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2239,12 +2239,14 @@ static void reach_filter(struct ref_array *array,
 {
 	struct rev_info revs;
 	int i, old_nr;
-	struct commit **to_clear = xcalloc(sizeof(struct commit *), array->nr);
+	struct commit **to_clear;
 	struct commit_list *cr;

 	if (!check_reachable)
 		return;

+	to_clear = xcalloc(sizeof(struct commit *), array->nr);
+
 	repo_init_revisions(the_repository, &revs, NULL);

 	for (i = 0; i < array->nr; i++) {
--
2.28.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ref-filter: plug memory leak in reach_filter()
  2020-09-26  8:37 [PATCH] ref-filter: plug memory leak in reach_filter() René Scharfe
@ 2020-09-26 14:53 ` Aaron Lipman
  2020-09-26 22:40   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Aaron Lipman @ 2020-09-26 14:53 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano

Thanks for catching that!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ref-filter: plug memory leak in reach_filter()
  2020-09-26 14:53 ` Aaron Lipman
@ 2020-09-26 22:40   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-09-26 22:40 UTC (permalink / raw)
  To: Aaron Lipman; +Cc: René Scharfe, Git Mailing List

Aaron Lipman <alipman88@gmail.com> writes:

> Thanks for catching that!

Yeah, looks good.  Thanks, both.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-26 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-26  8:37 [PATCH] ref-filter: plug memory leak in reach_filter() René Scharfe
2020-09-26 14:53 ` Aaron Lipman
2020-09-26 22:40   ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git