Skip to content

Commit 3fbfbbb

Browse files
peffgitster
authored andcommitted
list_objects_filter_copy(): deep-copy sparse_oid_name field
The purpose of our copy function is to do a deep copy of each field so that the source and destination structs become independent. We correctly copy the filter_spec string list, but we forgot the sparse_oid_name field. By doing a shallow copy of the pointer, that puts us at risk for a use-after-free if one or both of the structs is cleaned up. I don't think this can be triggered in practice, because we tend to leak the structs rather than actually clean them up. But this should future-proof us for plugging those leaks. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac8035a commit 3fbfbbb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

list-objects-filter-options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void list_objects_filter_copy(
418418
string_list_init_dup(&dest->filter_spec);
419419
for_each_string_list_item(item, &src->filter_spec)
420420
string_list_append(&dest->filter_spec, item->string);
421+
dest->sparse_oid_name = xstrdup_or_null(src->sparse_oid_name);
421422

422423
ALLOC_ARRAY(dest->sub, dest->sub_alloc);
423424
for (i = 0; i < src->sub_nr; i++)

0 commit comments

Comments
 (0)