git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* [PATCH] dir-iterator: release strbuf after use
@ 2019-08-07 11:15 René Scharfe
  0 siblings, 0 replies; only message in thread
From: René Scharfe @ 2019-08-07 11:15 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Matheus Tavares

Signed-off-by: René Scharfe <l.s.r@web.de>
---
Patch generated with --function-context for easier review.

The plugged leak was added after v2.22.0 (2019-06-07) by 3012397e03
(dir-iterator: refactor state machine model, 2019-07-10).

 refs/files-backend.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index b1f8f53a09..d60767ab73 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2143,24 +2143,26 @@ static struct ref_iterator_vtable files_reflog_iterator_vtable = {
 static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
 						  const char *gitdir)
 {
 	struct dir_iterator *diter;
 	struct files_reflog_iterator *iter;
 	struct ref_iterator *ref_iterator;
 	struct strbuf sb = STRBUF_INIT;

 	strbuf_addf(&sb, "%s/logs", gitdir);

 	diter = dir_iterator_begin(sb.buf, 0);
-	if(!diter)
+	if (!diter) {
+		strbuf_release(&sb);
 		return empty_ref_iterator_begin();
+	}

 	iter = xcalloc(1, sizeof(*iter));
 	ref_iterator = &iter->base;

 	base_ref_iterator_init(ref_iterator, &files_reflog_iterator_vtable, 0);
 	iter->dir_iterator = diter;
 	iter->ref_store = ref_store;
 	strbuf_release(&sb);

 	return ref_iterator;
 }
--
2.22.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-07 11:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 11:15 [PATCH] dir-iterator: release strbuf after use René Scharfe

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 the 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