Skip to content

Commit e4d03b7

Browse files
nicolas-guichardgitster
authored andcommitted
load_branch_decorations: fix memory leak with non-static filters
load_branch_decorations calls normalize_glob_ref on each string of filter's string_lists. This effectively replaces the potentially non-owning char* of those items with an owning char*. Set the strdup_string flag on those string_lists. This was not caught until now because: - when passing string_lists already with the strdup_string already set, the behaviour was correct - when passing static string_lists, the new char* remain reachable until program exit Signed-off-by: Nicolas Guichard <[email protected]> Acked-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 777489f commit e4d03b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

log-tree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ void load_ref_decorations(struct decoration_filter *filter, int flags)
232232
for_each_string_list_item(item, filter->exclude_ref_config_pattern) {
233233
normalize_glob_ref(item, NULL, item->string);
234234
}
235+
236+
/* normalize_glob_ref duplicates the strings */
237+
filter->exclude_ref_pattern->strdup_strings = 1;
238+
filter->include_ref_pattern->strdup_strings = 1;
239+
filter->exclude_ref_config_pattern->strdup_strings = 1;
235240
}
236241
decoration_loaded = 1;
237242
decoration_flags = flags;

0 commit comments

Comments
 (0)