Skip to content

Commit 7e9d856

Browse files
committed
line-log: avoid redundant copy that leaks in process_ranges
When bloom_filter_check() indicates that a commit does not touch any of the tracked paths, line_log_process_ranges_arbitrary_commit() propagates the current ranges to the parent by calling line_log_data_copy() and passing the copy to add_line_range(). However, add_line_range() always makes its own copy internally (via line_log_data_copy or line_log_data_merge), so the caller's copy is never freed and leaks every time this path is taken. Pass range directly to add_line_range() instead of making a redundant intermediate copy. The callee's internal copy handles ownership correctly. Pointed out by Coverity. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 711c911 commit 7e9d856

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

line-log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,7 @@ int line_log_process_ranges_arbitrary_commit(struct rev_info *rev, struct commit
11531153

11541154
if (range) {
11551155
if (commit->parents && !bloom_filter_check(rev, commit, range)) {
1156-
struct line_log_data *prange = line_log_data_copy(range);
1157-
add_line_range(rev, commit->parents->item, prange);
1156+
add_line_range(rev, commit->parents->item, range);
11581157
clear_commit_line_range(rev, commit);
11591158
} else if (commit->parents && commit->parents->next)
11601159
changed = process_ranges_merge_commit(rev, commit, range);

0 commit comments

Comments
 (0)