{"thread":{"id":"49799","subject":"[PATCH] builtin/notes: remove unnecessary free","startedAt":"2018-11-11T09:50:50Z","lastAt":"2018-11-13T01:29:16Z","messageCount":3,"participants":["Carlo Marcelo Arenas Belón","Johan Herland","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"362934","messageId":"20181111094933.27325-1-carenas@gmail.com","threadId":"49799","inReplyTo":null,"subject":"[PATCH] builtin/notes: remove unnecessary free","fromName":"Carlo Marcelo Arenas Belón","fromEmail":"carenas@gmail.com","sentAt":"2018-11-11T09:49:33Z","receivedAt":"2018-11-11T09:50:50Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"511726e4b1 (\"builtin/notes: fix premature failure when trying to add\nthe empty blob\", 2014-11-09) removed the check for !len but left a\ncall to free the buffer that will be otherwise NULL\n\nSigned-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n---\n builtin/notes.c | 4 +---\n 1 file changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex c05cd004ab..68062f7475 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -255,10 +255,8 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \n \tif (get_oid(arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(buf = read_object_file(&object, &type, &len))) {\n-\t\tfree(buf);\n+\tif (!(buf = read_object_file(&object, &type, &len)))\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n-\t}\n \tif (type != OBJ_BLOB) {\n \t\tfree(buf);\n \t\tdie(_(\"cannot read note data from non-blob object '%s'.\"), arg);\n-- \n2.19.1.856.g8858448bb\n\n"},{"id":"362937","messageId":"CALKQrgdCNxXSOG-KRUeNaw2q=hOGh9+-zM5ATHwmDEmOC7UAcw@mail.gmail.com","threadId":"49799","inReplyTo":"20181111094933.27325-1-carenas@gmail.com","subject":"Re: [PATCH] builtin/notes: remove unnecessary free","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2018-11-11T10:41:02Z","receivedAt":"2018-11-11T10:57:40Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Sun, Nov 11, 2018 at 10:49 AM Carlo Marcelo Arenas Belón\n<carenas@gmail.com> wrote:\n>\n> 511726e4b1 (\"builtin/notes: fix premature failure when trying to add\n> the empty blob\", 2014-11-09) removed the check for !len but left a\n> call to free the buffer that will be otherwise NULL\n>\n> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n\nSigned-off-by: Johan Herland <johan@herland.net>\n\n> ---\n>  builtin/notes.c | 4 +---\n>  1 file changed, 1 insertion(+), 3 deletions(-)\n>\n> diff --git a/builtin/notes.c b/builtin/notes.c\n> index c05cd004ab..68062f7475 100644\n> --- a/builtin/notes.c\n> +++ b/builtin/notes.c\n> @@ -255,10 +255,8 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n>\n>         if (get_oid(arg, &object))\n>                 die(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n> -       if (!(buf = read_object_file(&object, &type, &len))) {\n> -               free(buf);\n> +       if (!(buf = read_object_file(&object, &type, &len)))\n>                 die(_(\"failed to read object '%s'.\"), arg);\n> -       }\n>         if (type != OBJ_BLOB) {\n>                 free(buf);\n>                 die(_(\"cannot read note data from non-blob object '%s'.\"), arg);\n> --\n> 2.19.1.856.g8858448bb\n>\n\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"363116","messageId":"xmqqh8glzrx8.fsf@gitster-ct.c.googlers.com","threadId":"49799","inReplyTo":"CALKQrgdCNxXSOG-KRUeNaw2q=hOGh9+-zM5ATHwmDEmOC7UAcw@mail.gmail.com","subject":"Re: [PATCH] builtin/notes: remove unnecessary free","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-13T01:29:07Z","receivedAt":"2018-11-13T01:29:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> On Sun, Nov 11, 2018 at 10:49 AM Carlo Marcelo Arenas Belón\n> <carenas@gmail.com> wrote:\n>>\n>> 511726e4b1 (\"builtin/notes: fix premature failure when trying to add\n>> the empty blob\", 2014-11-09) removed the check for !len but left a\n>> call to free the buffer that will be otherwise NULL\n\nWow, that's a old one.\n\n>>\n>> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n>\n> Signed-off-by: Johan Herland <johan@herland.net>\n\nThanks, both.  Will apply.\n\n"}]}