Skip to content

Commit dd49699

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f0e86a commit dd49699

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ static int disconnect_git(struct transport *transport)
895895
finish_connect(data->conn);
896896
}
897897

898+
list_objects_filter_release(&data->options.filter_options);
898899
free(data);
899900
return 0;
900901
}

0 commit comments

Comments
 (0)