]> git.ipfire.org Git - thirdparty/git.git/commit - transport.c
transport: free filter options in disconnect_git()
authorJeff King <peff@peff.net>
Thu, 8 Sep 2022 04:58:11 +0000 (00:58 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Sep 2022 18:07:58 +0000 (11:07 -0700)
commitdd49699d12a81aa344bb44c882eeddbe799c666f
tree3e9269d899e5d8533a293c16305683bc91b2e2af
parent3f0e86a158e85de20537e8b2c8531d09802433ba
transport: free filter options in disconnect_git()

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
transport.c