git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Derrick Stolee <derrickstolee@github.com>
Subject: [PATCH 3/5] transport: free filter options in disconnect_git()
Date: Thu, 8 Sep 2022 00:58:11 -0400	[thread overview]
Message-ID: <Yxl2Yz8bg9T0dBGo@coredump.intra.peff.net> (raw)
In-Reply-To: <Yxl1BNQoy6Drf0Oe@coredump.intra.peff.net>

If a user of the transport API calls transport_set_option() with
TRANS_OPT_LIST_OBJECTS_FILTER, it doesn't pass a struct, but rather a
string with the filter-spec, which the transport code then stores in its
own list_objects_filter_options struct.

When the caller is done and we call transport_disconnect(), the contents
of that filter struct are then leaked. We should release it before
freeing the transport struct.

Another way to solve this would be for transport_set_option() to pass a
pointer to the struct. But that's awkward, because there's a generic
transport-option interface that always takes a string. Plus it opens up
questions of memory lifetimes; by storing its own filter-options struct,
the transport code remains self-contained.

Signed-off-by: Jeff King <peff@peff.net>
---
 transport.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/transport.c b/transport.c
index 24540f642a..6ec6130852 100644
--- a/transport.c
+++ b/transport.c
@@ -895,6 +895,7 @@ static int disconnect_git(struct transport *transport)
 		finish_connect(data->conn);
 	}
 
+	list_objects_filter_release(&data->options.filter_options);
 	free(data);
 	return 0;
 }
-- 
2.37.3.1139.g47294c03c7


  parent reply	other threads:[~2022-09-08  4:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  4:52 [PATCH 0/5] plugging some list-objects-filter leaks Jeff King
2022-09-08  4:54 ` [PATCH 1/5] list_objects_filter_copy(): deep-copy sparse_oid_name field Jeff King
2022-09-08  4:57 ` [PATCH 2/5] transport: deep-copy object-filter struct for fetch-pack Jeff King
2022-09-08  4:58 ` Jeff King [this message]
2022-09-08  5:01 ` [PATCH 4/5] list_objects_filter_options: plug leak of filter_spec strings Jeff King
2022-09-08  5:02 ` [PATCH 5/5] prepare_repo_settings(): plug leak of config values Jeff King
2022-09-09 14:20 ` [PATCH 0/5] plugging some list-objects-filter leaks Derrick Stolee
2022-09-11  4:51   ` Jeff King

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=Yxl2Yz8bg9T0dBGo@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    /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).