Re: [PATCH 05/13] run_diff_files: avoid memory leak
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jul 1, 2026, 07:56 UTC
- Message-ID
- <akTIMM6qLfDNdg-a@pks.im>
- In-Reply-To
- <860bc8f52dc9be8bbfafcda296be831a1ffaf1c2.1782889472.git.gitgitgadget@gmail.com>
On Wed, Jul 01, 2026 at 07:04:23AM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 21 quoted lines
> 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