Skip to content

Commit fe6a01a

Browse files
peffgitster
authored andcommitted
add: free leaked pathspec after add_files_to_cache()
After run_diff_files, we throw away the rev_info struct, including the pathspec that we copied into it, leaking the memory. this is probably not a big deal in practice. We usually only run this once per process, and the leak is proportional to the pathspec list we're already holding in memory. But it's still a leak, and it pollutes leak-checker output, making it harder to find important leaks. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 85b81b3 commit fe6a01a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

builtin/add.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ int add_files_to_cache(const char *prefix,
119119
rev.diffopt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;
120120
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
121121
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
122+
clear_pathspec(&rev.prune_data);
122123
return !!data.add_errors;
123124
}
124125

0 commit comments

Comments
 (0)