Re: [PATCH 05/13] run_diff_files: avoid memory leak
From: Patrick Steinhardt <hidden>
Date: 2026-07-01 07:56:36
On Wed, Jul 01, 2026 at 07:04:23AM +0000, Johannes Schindelin via GitGitGadget wrote:
quoted hunk ↗ jump to hunk
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;
Huh. There is no assignment between the variable declaration and this call to `continue`, so how could this ever plug a memory leak? None of the other paths seem to leak the variable, either. Patrick