diff mbox series

[2/2] read-cache: free hash context in do_write_index()

Message ID b6fe5b3ef7e5f4ac8cc339685d92e3ac39fcb456.1727696424.git.gitgitgadget@gmail.com (mailing list archive)
State New
Headers show
Series read-cache: two small leak fixes | expand

Commit Message

Derrick Stolee Sept. 30, 2024, 11:40 a.m. UTC
From: Derrick Stolee <stolee@gmail.com>

While writing an index, a 'git_hash_ctx' is allocated for hashing the
file contents. This should be freed as the method exits.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
 read-cache.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Patrick Steinhardt Sept. 30, 2024, 12:32 p.m. UTC | #1
On Mon, Sep 30, 2024 at 11:40:24AM +0000, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <stolee@gmail.com>
> 
> While writing an index, a 'git_hash_ctx' is allocated for hashing the
> file contents. This should be freed as the method exits.
> 
> Signed-off-by: Derrick Stolee <stolee@gmail.com>
> ---
>  read-cache.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/read-cache.c b/read-cache.c
> index 3c078afadbc..51845c2e611 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -3126,6 +3126,7 @@ out:
>  		free_hashfile(f);
>  	strbuf_release(&sb);
>  	free(ieot);
> +	free(eoie_c);
>  	return ret;
>  }

Yup, this one looks correct. I've sent out an equivalent patch via [1] a
couple hours ago.

Patrick

[1]: https://lore.kernel.org/git/c51f40c5bd0c56967e348363e784222de7884b79.1727687410.git.ps@pks.im/
Derrick Stolee Oct. 1, 2024, 10:01 a.m. UTC | #2
On 9/30/24 8:32 AM, Patrick Steinhardt wrote:
> On Mon, Sep 30, 2024 at 11:40:24AM +0000, Derrick Stolee via GitGitGadget wrote:
>> From: Derrick Stolee <stolee@gmail.com>

>> diff --git a/read-cache.c b/read-cache.c
>> index 3c078afadbc..51845c2e611 100644
>> --- a/read-cache.c
>> +++ b/read-cache.c
>> @@ -3126,6 +3126,7 @@ out:
>>   		free_hashfile(f);
>>   	strbuf_release(&sb);
>>   	free(ieot);
>> +	free(eoie_c);
>>   	return ret;
>>   }
> 
> Yup, this one looks correct. I've sent out an equivalent patch via [1] a
> couple hours ago.
> 
> Patrick
> 
> [1]: https://lore.kernel.org/git/c51f40c5bd0c56967e348363e784222de7884b79.1727687410.git.ps@pks.im/

Sorry for the collision. I had checked when prepping the GGG PR on
Friday but forgot to check again before submitting. Your patch is
better in substance and context.

Thanks,
-Stolee
Patrick Steinhardt Oct. 1, 2024, 10:16 a.m. UTC | #3
On Tue, Oct 01, 2024 at 06:01:06AM -0400, Derrick Stolee wrote:
> On 9/30/24 8:32 AM, Patrick Steinhardt wrote:
> > On Mon, Sep 30, 2024 at 11:40:24AM +0000, Derrick Stolee via GitGitGadget wrote:
> > > From: Derrick Stolee <stolee@gmail.com>
> 
> > > diff --git a/read-cache.c b/read-cache.c
> > > index 3c078afadbc..51845c2e611 100644
> > > --- a/read-cache.c
> > > +++ b/read-cache.c
> > > @@ -3126,6 +3126,7 @@ out:
> > >   		free_hashfile(f);
> > >   	strbuf_release(&sb);
> > >   	free(ieot);
> > > +	free(eoie_c);
> > >   	return ret;
> > >   }
> > 
> > Yup, this one looks correct. I've sent out an equivalent patch via [1] a
> > couple hours ago.
> > 
> > Patrick
> > 
> > [1]: https://lore.kernel.org/git/c51f40c5bd0c56967e348363e784222de7884b79.1727687410.git.ps@pks.im/
> 
> Sorry for the collision. I had checked when prepping the GGG PR on
> Friday but forgot to check again before submitting. Your patch is
> better in substance and context.

Nothing to be sorry about, both series were sent out quite close to one
another. Quite on the contrary, thanks for fixing this leak :)

I don't mind much which of these versions lands in the tree, and the
resulting conflict is trivial to solve anyway.

Patrick
diff mbox series

Patch

diff --git a/read-cache.c b/read-cache.c
index 3c078afadbc..51845c2e611 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3126,6 +3126,7 @@  out:
 		free_hashfile(f);
 	strbuf_release(&sb);
 	free(ieot);
+	free(eoie_c);
 	return ret;
 }