mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
entry: fix leaking pathnames during delayed checkout
When filtering files during delayed checkout, we pass a string list to `async_query_available_blobs()`. This list is initialized with NODUP, and thus inserted strings will not be owned by the list. In the latter function we then try to hand over ownership by passing an `xstrup()`'d value to `string_list_insert()`. But this is not how this works: a NODUP list does not take ownership of allocated strings and will never free them for the caller. Fix this issue by initializing the list as `DUP` instead and dropping the explicit call to `xstrdup()`. This is okay to do given that this is the single callsite of `async_query_available_blobs()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
57fb139b5e
commit
1f08999781
4
entry.c
4
entry.c
@@ -191,7 +191,7 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
|
||||
progress = start_delayed_progress(_("Filtering content"), dco->paths.nr);
|
||||
while (dco->filters.nr > 0) {
|
||||
for_each_string_list_item(filter, &dco->filters) {
|
||||
struct string_list available_paths = STRING_LIST_INIT_NODUP;
|
||||
struct string_list available_paths = STRING_LIST_INIT_DUP;
|
||||
|
||||
if (!async_query_available_blobs(filter->string, &available_paths)) {
|
||||
/* Filter reported an error */
|
||||
@@ -245,6 +245,8 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
|
||||
} else
|
||||
errs = 1;
|
||||
}
|
||||
|
||||
string_list_clear(&available_paths, 0);
|
||||
}
|
||||
|
||||
filter_string_list(&dco->filters, 0, string_is_not_null, NULL);
|
||||
|
||||
Reference in New Issue
Block a user