{"thread":{"id":"37310","subject":"[PATCH] builtin/log.c: fix minor memory leak","startedAt":"2014-08-07T17:13:37Z","lastAt":"2014-08-07T19:28:41Z","messageCount":3,"participants":["Matthieu Moy","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"247443","messageId":"1407431617-4156-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"37310","inReplyTo":null,"subject":"[PATCH] builtin/log.c: fix minor memory leak","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2014-08-07T17:13:37Z","receivedAt":"2014-08-07T17:13:37Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nValgrind confirms, one less unreachable block ;-).\n\n builtin/log.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 4389722..e4d8122 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -857,20 +857,21 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)\n {\n \tstruct strbuf desc = STRBUF_INIT;\n \tif (!branch_name || !*branch_name)\n \t\treturn;\n \tread_branch_desc(&desc, branch_name);\n \tif (desc.len) {\n \t\tstrbuf_addch(buf, '\\n');\n \t\tstrbuf_addbuf(buf, &desc);\n \t\tstrbuf_addch(buf, '\\n');\n \t}\n+\tstrbuf_release(&desc);\n }\n \n static char *find_branch_name(struct rev_info *rev)\n {\n \tint i, positive = -1;\n \tunsigned char branch_sha1[20];\n \tconst unsigned char *tip_sha1;\n \tconst char *ref, *v;\n \tchar *full_ref, *branch = NULL;\n \n-- \n2.0.2.737.gfb43bde\n"},{"id":"247447","messageId":"20140807180435.GD12427@google.com","threadId":"37310","inReplyTo":"1407431617-4156-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] builtin/log.c: fix minor memory leak","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-08-07T18:04:35Z","receivedAt":"2014-08-07T18:04:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Matthieu Moy wrote:\n\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n> Valgrind confirms, one less unreachable block ;-).\n\nThis belongs in the commit message.\n\n[...]\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -857,20 +857,21 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)\n>  {\n>  \tstruct strbuf desc = STRBUF_INIT;\n>  \tif (!branch_name || !*branch_name)\n>  \t\treturn;\n>  \tread_branch_desc(&desc, branch_name);\n>  \tif (desc.len) {\n>  \t\tstrbuf_addch(buf, '\\n');\n>  \t\tstrbuf_addbuf(buf, &desc);\n>  \t\tstrbuf_addch(buf, '\\n');\n>  \t}\n> +\tstrbuf_release(&desc);\n\nThis is an old one.  The leak was introduced by v1.7.9-rc1~1^2~12\n(format-patch: use branch description in cover letter, 2011-09-21).\n\nI was a little scared to see a leak in 'git log' code, since most of\nwhat log does involves looping over many commits.  Luckily this one is\nonly used in make_cover_letter to create a cover letter describing the\nsingle branch on the command line, making it is a small, one-time\nleak.\n\nLess noise from static and dynamic analysis tools is still worthwhile,\nso for what it's worth,\n\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n\nThanks.\n"},{"id":"247452","messageId":"xmqq1tssksk6.fsf@gitster.dls.corp.google.com","threadId":"37310","inReplyTo":"20140807180435.GD12427@google.com","subject":"Re: [PATCH] builtin/log.c: fix minor memory leak","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-08-07T19:28:41Z","receivedAt":"2014-08-07T19:28:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Matthieu Moy wrote:\n>\n>> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n>> ---\n>> Valgrind confirms, one less unreachable block ;-).\n>\n> This belongs in the commit message.\n>\n> [...]\n>> --- a/builtin/log.c\n>> +++ b/builtin/log.c\n>> @@ -857,20 +857,21 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)\n>>  {\n>>  \tstruct strbuf desc = STRBUF_INIT;\n>>  \tif (!branch_name || !*branch_name)\n>>  \t\treturn;\n>>  \tread_branch_desc(&desc, branch_name);\n>>  \tif (desc.len) {\n>>  \t\tstrbuf_addch(buf, '\\n');\n>>  \t\tstrbuf_addbuf(buf, &desc);\n>>  \t\tstrbuf_addch(buf, '\\n');\n>>  \t}\n>> +\tstrbuf_release(&desc);\n>\n> This is an old one.  The leak was introduced by v1.7.9-rc1~1^2~12\n> (format-patch: use branch description in cover letter, 2011-09-21).\n>\n> I was a little scared to see a leak in 'git log' code, since most of\n> what log does involves looping over many commits.  Luckily this one is\n> only used in make_cover_letter to create a cover letter describing the\n> single branch on the command line, making it is a small, one-time\n> leak.\n\nExactly ;-).\n\n>\n> Less noise from static and dynamic analysis tools is still worthwhile,\n> so for what it's worth,\n>\n> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n>\n> Thanks.\n\nThanks.\n"}]}