From: Johannes Schindelin via GitGitGadget Date: Wed, 01 Jul 2026 07:04:23 GMT Subject: [PATCH 05/13] run_diff_files: avoid memory leak Message-ID: <860bc8f52dc9be8bbfafcda296be831a1ffaf1c2.1782889472.git.gitgitgadget@gmail.com> In-Reply-To: From: Johannes Schindelin In 4fc970c4388 (diff --cc: fix display of symlink conflicts during a merge., 2007-02-25) a conditional block was introduced in `run_diff_files()` that skips the rest of the loop iteration and advances directly to the next iteration. However, it missed that there was a similar conditional block that was last touched in b4b1550315c (Don't instantiate structures with FAMs., 2006-06-18) and which demonstrated that the `dpath` structure needed to be released. Let's fix this. Pointed out by Coverity. Signed-off-by: Johannes Schindelin --- diff-lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diff-lib.c b/diff-lib.c index ae91027a02..7ba839b4a8 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -152,7 +152,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option) continue; if (ce_stage(ce)) { - struct combine_diff_path *dpath; + struct combine_diff_path *dpath = NULL; struct diff_filepair *pair; unsigned int wt_mode = 0; int num_compare_stages = 0; @@ -164,6 +164,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option) else { if (changed < 0) { perror(ce->name); + free(dpath); continue; } wt_mode = 0; -- gitgitgadget