All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] builtin/log.c: fix minor memory leak
@ 2014-08-07 17:13 Matthieu Moy
  2014-08-07 18:04 ` Jonathan Nieder
  0 siblings, 1 reply; 3+ messages in thread
From: Matthieu Moy @ 2014-08-07 17:13 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Valgrind confirms, one less unreachable block ;-).

 builtin/log.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/log.c b/builtin/log.c
index 4389722..e4d8122 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -857,20 +857,21 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
 {
 	struct strbuf desc = STRBUF_INIT;
 	if (!branch_name || !*branch_name)
 		return;
 	read_branch_desc(&desc, branch_name);
 	if (desc.len) {
 		strbuf_addch(buf, '\n');
 		strbuf_addbuf(buf, &desc);
 		strbuf_addch(buf, '\n');
 	}
+	strbuf_release(&desc);
 }
 
 static char *find_branch_name(struct rev_info *rev)
 {
 	int i, positive = -1;
 	unsigned char branch_sha1[20];
 	const unsigned char *tip_sha1;
 	const char *ref, *v;
 	char *full_ref, *branch = NULL;
 
-- 
2.0.2.737.gfb43bde

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] builtin/log.c: fix minor memory leak
  2014-08-07 17:13 [PATCH] builtin/log.c: fix minor memory leak Matthieu Moy
@ 2014-08-07 18:04 ` Jonathan Nieder
  2014-08-07 19:28   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Nieder @ 2014-08-07 18:04 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, gitster

Matthieu Moy wrote:

> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> Valgrind confirms, one less unreachable block ;-).

This belongs in the commit message.

[...]
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -857,20 +857,21 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
>  {
>  	struct strbuf desc = STRBUF_INIT;
>  	if (!branch_name || !*branch_name)
>  		return;
>  	read_branch_desc(&desc, branch_name);
>  	if (desc.len) {
>  		strbuf_addch(buf, '\n');
>  		strbuf_addbuf(buf, &desc);
>  		strbuf_addch(buf, '\n');
>  	}
> +	strbuf_release(&desc);

This is an old one.  The leak was introduced by v1.7.9-rc1~1^2~12
(format-patch: use branch description in cover letter, 2011-09-21).

I was a little scared to see a leak in 'git log' code, since most of
what log does involves looping over many commits.  Luckily this one is
only used in make_cover_letter to create a cover letter describing the
single branch on the command line, making it is a small, one-time
leak.

Less noise from static and dynamic analysis tools is still worthwhile,
so for what it's worth,

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] builtin/log.c: fix minor memory leak
  2014-08-07 18:04 ` Jonathan Nieder
@ 2014-08-07 19:28   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2014-08-07 19:28 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Matthieu Moy, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> Matthieu Moy wrote:
>
>> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
>> ---
>> Valgrind confirms, one less unreachable block ;-).
>
> This belongs in the commit message.
>
> [...]
>> --- a/builtin/log.c
>> +++ b/builtin/log.c
>> @@ -857,20 +857,21 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
>>  {
>>  	struct strbuf desc = STRBUF_INIT;
>>  	if (!branch_name || !*branch_name)
>>  		return;
>>  	read_branch_desc(&desc, branch_name);
>>  	if (desc.len) {
>>  		strbuf_addch(buf, '\n');
>>  		strbuf_addbuf(buf, &desc);
>>  		strbuf_addch(buf, '\n');
>>  	}
>> +	strbuf_release(&desc);
>
> This is an old one.  The leak was introduced by v1.7.9-rc1~1^2~12
> (format-patch: use branch description in cover letter, 2011-09-21).
>
> I was a little scared to see a leak in 'git log' code, since most of
> what log does involves looping over many commits.  Luckily this one is
> only used in make_cover_letter to create a cover letter describing the
> single branch on the command line, making it is a small, one-time
> leak.

Exactly ;-).

>
> Less noise from static and dynamic analysis tools is still worthwhile,
> so for what it's worth,
>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
>
> Thanks.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-07 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-07 17:13 [PATCH] builtin/log.c: fix minor memory leak Matthieu Moy
2014-08-07 18:04 ` Jonathan Nieder
2014-08-07 19:28   ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.